-4
나는이 코드를 실행하면이 오류가 발생합니다. 이 문제를 해결하려면 도움을 주시면 대단히 감사하겠습니다.컴파일 할 수없는 소스 코드 - 비 정적 변수 Jim
오류 :
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static variable Jim cannot be referenced from a static context
at debugmetwo.BigAppleCount.generateBigAppleCount(BigAppleCount.java:7)
at debugmetwo.BigAppleCountTest.main(BigAppleCountTest.java:10)
Java Result: 1
홈페이지 :
package AppleCount;
public class BigAppleCountTest {
public static void main(String[] args) {
BigAppleCount bac = new BigAppleCount();
bac.generateBigAppleCount();
}
}
등급 :
package AppleCount;
public class AppleCount {
public int Jim = 10;
public int Gray = 15;
public int Bill = 16;
}
서브 클래스
package AppleCount;
public class BigAppleCount {
public void generateBigAppleCount(){
System.out.printf("How many apple Jim has: %,d\n",
AppleCount.Jim);
System.out.printf("How many apple Gray has: %,d\n",
AppleCount.Gray);
System.out.printf("How many apple Bill has: %,d\n",
AppleCount.Bill);
}
}
오류 메시지를 조사한 결과 어떤 결과를 얻었습니까? –