static (1) 썸네일형 리스트형 static - 정적 변수, 정적 메소드 static 선언 클래스 변수 클래스 변수 : 인스턴스의 생성과 상관 없이 존재하는 변수 인스턴스 생성하지 않아도 호출 가능하다 static로 선언된 변수는 변수가 선언된 클래스의 모든 인스턴스를 공유하는 변수이다 int num = 0; - > 인스턴스 변수 static int num = 0; -> 클래스 변수 class InstCnt { static int instNum = 0; void InstCnt2() { instNum++; System.out.println(instNum); } } public class callStatic { public static void main(String[] arg) { InstCnt AA= new InstCnt(); AA.InstCnt2(); //1 AA.InstCn.. 이전 1 다음