作者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