static
static 변수(정적 변수, 클래스 변수), static method(클래스 메소드)
Test test = new Test();
class ScjpPass{
//멤버 변수, Heap
int t1=0;
int t2=0;
int t3=0;
int t4=0;
//클래스 변수, Data area
static int BONUS=100;
//생성자, Source area
public ScjpPass(){
}
//생성자, this = sp객체가 가지고 있는 hash code
//sp객체의 heap메모리를 공유하게됩니다.
//int t1, int t2, int t3, int t4: Stack
public ScjpPass(int t1, int t2, int t3, int t4){
//Heap = Stack
//전역 변수 = 지역 변수
//멤버 변수 = 지역 변수
this.t1 = t1;
this.t2 = t2;
this.t3 = t3;
this.t4 = t4;
}
}static 메소드는 객체를 만들지 않고도 호출할 수 있습니다.
static 에서의 초기화 유무.
static 의 활용 분야
값을 변경할 수 없는 final 변수(상수 선언)
Last updated