본문 바로가기

자바의 정석 정리

자바의 정석 - 5.3 가변 배열

5.3.1 가변 배열

  • 초기 생성시에 열의 개수를 지정하지 않음
  • 추후에 각기 다른 배열을 생성함으로써 다른 길이의 배열 선언
    int[][] score = new int[5][];
    socore[0] = new int[4];
    socore[1] = new int[3];
    socore[2] = new int[2];
    socore[3] = new int[2];
    socore[4] = new int[3];
    int[][] score = {
                                      {100, 100, 100, 100}
                                      ,{20, 20, 20}
                                      ,{30, 30}
                                      ,{40, 40}
                                      ,{50, 50, 50}
                                  }