[問題] 關於auto-boxing一問?
class Target{
private int i=0;
public int addOne(){
return ++i;
}
}
public class ex178{
public static void main(String[] args){
System.out.println(new Target().addOne());
}
}
題目:
which change can you make to Target without affecting Client?
答案是
Line 2 of class Target can be changed to private Integer i=0;
但我改了第二行為 private Integer i =0; 結果輸出也是變1了??
依題意是不變的意思嗎?? 仍為0嗎?? 還是我誤會題目嗎??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.46.125.199
→
08/29 18:38, , 1F
08/29 18:38, 1F
→
08/29 18:40, , 2F
08/29 18:40, 2F
→
08/29 18:49, , 3F
08/29 18:49, 3F
→
08/29 18:57, , 4F
08/29 18:57, 4F
推
08/29 20:04, , 5F
08/29 20:04, 5F
→
08/29 20:39, , 6F
08/29 20:39, 6F
→
08/29 20:40, , 7F
08/29 20:40, 7F