public class Test {
Integer i;
int j;
public static void main(String[] args) {
Test t = new Test();
t.go();
}
public void go() {
j = i;
System.out.println(j);
System.out.println(i);
}
}
Integer i;// 包含 null //
包含int j;0null = 0NullPointerException
给定代码
相当于这个
你有
i == null。在空对象上调用方法会导致 NPE