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();
}
}
}
'프로그래밍 언어 > JAVA(자바) 응용' 카테고리의 다른 글
21.ArrayList를 활용한 간단한 성적 산출 프로그램 (0) | 2022.05.23 |
---|---|
20.객체 배열을 구현한 클래스 ArrayList (0) | 2022.05.22 |
18.객체 배열 (0) | 2022.05.22 |
17.배열(array) (0) | 2022.05.22 |
16.Static 응용 -싱글톤 패턴 (0) | 2022.05.22 |
댓글