Network disconnected
Description
static 메소드는 static한 필드(속성)만 사용할 수 있습니다. 그런데 주어진 코드는 static 메소드인 main method에서 static 하지 않은 변수, value를 쓰려고해 오류가 발생합니다. 코드가 정상적으로 동작하도록 코드를 수정해보세요.
힌트1
static 과 non-static
public class VariableScopeExam {
int globalScope = 10; // 인스턴스 변수
static int staticVal = 7; // 클래스 변수
public void scopeTest(int value) {
int localScope = 20; //지역변수
}
public static void main(String[] args) {
System.out.println(staticVal); // 클래스 변수는 인스턴스화 하지 않고도 사용가능
System.out.println(globalScope); // 오류
}
}
-
2번째 줄
int value = 10
을static int value = 10
으로 수정해보세요. ↩
Result
Stop
Result of [Run Test] or [Submit] will be displayed here