public class HelloWorld{ //Why is it throwing error here
final static int i;
public static void main(String []args){
int i = call(10);
System.out.println("Hello World"+i);
}
static int call(int y){
int r= y;
return r ;
}
}
위의 프로그램에서 final static int i;
을 사용하면 오류가 발생합니다. 아무도 정확히 왜 저에게 말할 수 있습니까? 같은 final static int i;
은 메서드 내에서 선언 할 때 잘 동작합니다.변수가 변수를 초기화하지 않았을 수 있음
오류 : 즉,이 행동하도록되어 방법이기 때문에
$javac HelloWorld.java 2>&1
HelloWorld.java:1: error: variable i might not have been initialized
public class HelloWorld{
^
1 error