초기화 블록
멤버 변수를 초기화하는 블록
class Test{
int a;
static int b;
//일반 초기화 블록
{
a = 10;
}
//static 초기화 블록
static{
b = 20;
}
}
멤버 변수의 초기값이 할당되는 순서
1. 멤버 변수에 대한 기본값 자동 할당
기본값: 숫자 유형(0) / 객체 유형(null) / 부울(false)
2. 멤버 변수 선언 시 할당된 값
3. 초기화 블록에 할당된 값
4. 생성자에 할당된 값
![[Spring] 유효성 검증 [Spring] 유효성 검증](https://en.korea-industry.kr/wp-content/plugins/contextual-related-posts/default.png)