public class TestClass { private static void staticMethod(){ System.out.println("static"); } void normalMethod(){ System.out.println("normal"); } public static void main(String[] args) { TestClass testClass=((TestClass)null); testClass.staticMethod(); testClass.normalMethod(); } }
I thought that a NullPointerException would be reported at the beginning
and the staticMethod() was actually executed. . .
The summary is as follows:
1.null can be casted to any object 2.null can be
casted to an object after calling the static method of the class without error
mark for reference