Static 메소드는 non-Static 메소드를 참조할 수 없다.
매우 간단하며, 누구나 알법한 내용이다.static 메소드에서 static이 아닌 메소드를 참조할 수 없다. 코드로 한 번 보자.1234567public class RenoV{ String hello = "Hello, RenoV!"; public static void main(String args[]){ System.out.println(hello); }}Colored by Color Scriptercs위 코드를 실행하면 오류가 발생한다.static 메소드인 main 안에서 static이 아닌 String인 hello를 참조했기 때문이다.이 코드가 올바르게 동작하려면 아래와 같이 수정해야 한다.1234567public class RenoV{ static String hello = "Hello, RenoV..
개발 이야기/Tip & Troubleshooting
2016. 2. 1. 09:06
공지사항