본문 바로가기

developer/자바의정석(기초편)

[자바의 정석(기초편)] 2차원 배열, String 클래스

2차원 배열 선언

int[][] score = new int[4][3];
score[0][0] score[0][1] score[0][2]
score[1][0] score[1][1] score[1][2]
score[2][0] score[2][1] score[2][2]
score[3][0] score[3][1] score[3][2]

2차원 배열 초기화

int[][] arr = {
                {1, 2, 3},
                {4, 5, 6}
        };

String class의 주요 method

substring

String str = "012345";
String tmp = str.substring(1, 4); // (int from, int to) from은 포함, to는 포함되지 않음
System.out.println(tmp); // 123

 

뭐라도 끄적이자...