더북(TheBook)
public class Main {
    public static void main(String[] args) {
        int a; ◀︎---------- 변수 선언
        int b = 10; ◀︎----- 변수 선언 및 초기화
        a = 11; ◀︎--------- 변수 초기화
        System.out.println(a);
        System.out.println(b);
    }
}

icon_con

실행결과

11
10

예제처럼 초기화는 변수 선언과 동시에 해도 되고 나중에 따로 해도 됩니다. 다만, 사용하기 전에는 반드시 초기화해야 합니다.