프로그래밍 언어/JAVA(자바) 응용
19.2차원 배열
lroot
2022. 5. 22. 18:07
728x90
반응형
다차원 배열
- 이차원 이상으로 구현 된 배열
- 평면(이차원 배열) 이나 공간(삼차원 배열)을 활용한 프로그램 구현
이차원 배열 예제
int[][] arr = { {1,2,3}, {4,5,6} }
- TwoDimensionTest.java
public class TwoDimensionTest {
public static void main(String[] args) {
int[][] arr= { {1,2,3}, {4,5,6,7}};
int i,j;
for(i=0; i<arr.length; i++)
{
for(j=0; j<arr[i].length; j++) {
System.out.print(arr[i][j]+",");
}
System.out.print("\t" + arr[i].length);
System.out.println();
}
}
}