public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(""+getA());
System.out.println(""+getA());
System.out.println(""+getA());
}
public static int getA(){
final int a= get();
return a;
}
static int a;
public static int get()
{
return ++a;
}
}
결과는 1, 2,,3 으로나온다.
단지 초기화된 후 고정되는것일 뿐인듯하다.
클래스안의 변수를 많이 줄일 수 있을듯.

댓글을 달아 주세요