객체의 속성 (멤버 변수)
작성법
[접근제한자] [예약어] class 클래스명 {
[접근제한자] [예약어] 자료형 변수명 [= 초기값];
}
ex)
public class Academy {
public int temp1;
protected int temp2;
int temp3;
private int temp4;
}
접근제한자
필드 예약어
public class Academy {
private static int temp1;
}
public class Academy {
private final int TEMP1 = 100;
private int temp4;
}
클래스 초기화 블록
[접근제한자] [예약어] class 클래스명 {
[접근제한자] static 자료형 필드1 = 10;
[접근제한자] 자료형 필드2 = 20;
static{ 필드1 = 30; }
{ 필드2 = 40; }
}