[code="java"]
public class Test1 {
public static void helloStatic(){
System.out.println("Hello Static ...");
}
public void helloDynamic(){
System.out.println("Hello Dynamic ...");
}
public static void main(String[] args) {
Test1 t1 = null;
t1.helloStatic();
t1.helloDynamic();
}
}
[/code]
[size=medium]上面的代码调用静态的就可以,调用非静态的方法代码就报错空指针。能解释下为什么吗?[/size]