STATIC
static에 대해서 알아보자
static 키워드란?
static 적용 범위
클래스(Class)
public class StaticCar {
static String _where="I am a Car from Germany!";
Country _country; // object of inner class country
StaticCar(){
_country=new Country(); // instantiate the inner class
}
static class Country { // static member inner class
String showCountry() {
return _where;
}
}
public static void main(String[] args) {
StaticCar myCar = new StaticCar() ; // instantiated object of class StaticCar
System.out.print("Access through an Country reference");
System.out.println(" created in an object of a StaticCar:");
System.out.println(myCar._country.showCountry());
// instantiated object of class StaticCar.Country
StaticCar.Country country = new StaticCar.Country();
System.out.println("Access through an Country reference that is local:");
System.out.println(country.showCountry());
}
}그렇다면 내부 클래스를 여러 개 생성할 경우 두개의 인스턴스는 동일한가?
변수(Variable)
함수(Method)
영역(Block)
호출 순서
static 메소드 적용 기준
static 데이터가 적재되는 Method Area란?
static 제약 조건
static 영역 내에선 static 변수만 사용가능하다.
static 영역 내에선 this 키워드를 사용할 수 없다.

참고
Last updated