作者FatDevil (You Are The One!!)
站內java
標題[問題] SCJP練習題
時間Mon Jan 7 21:45:50 2008
public class Test{
public int aMethod(){
static int i = 0;
i++;
return i;
}
public static void main(String args[]){
Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
請問一下是錯在哪阿?
我看解答是i一定要是final(當然沒有i++)這樣就可以了,why?
懇請各位高手指導
感謝~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.216.44.240
1F:推 hsiaoli:在method的變數是loacl variable, so我覺得應該要加~ 01/08 12:18