java 基础——问题
下面的代码编译可以通过,运行报错:
Exception in thread "main" java.lang.NullPointerException
at B.main(B.java:11)
import java.io.PrintStream;
public class B{
static PrintStream out;
public static void main(String args[]){
B.out.println("Hello World !");
}
}
import java.io.PrintStream;
public class B{
static PrintStream out = new PrintStream(System.out);
public static void main(String args[]){
B.out.println("Hello World !");
}
}