public class Test{
public static void hello() {
System.out.println("hello");
}
public static void main(String[]args){
((Test) null).hello();
}
}
代码是可以运行的。
任何对象都可以赋值为null。
(Test)null 不能调用Test中的普通方法,但可以调用Test中的静态方法。
(Test)null 不能调用对象的方法,但可以调用类的方法。