我希望NullPointerException
在以下程序的输出中出现 a,因为在go
方法内部,c2
为空。但它工作正常并打印 200。为什么?
class CardBoard {
Short story = 200;
CardBoard go(CardBoard cb) {
cb = null;
return cb;
}
public static void main(String[] args) {
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
System.out.print(c2.story); // dout here
}
}