Notice
Recent Posts
Recent Comments
Link
«   2024/06   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter04 : 2D_array 본문

JAVA/chapter05_array

chapter04 : 2D_array

GAWON 2023. 5. 26. 09:19
package org.joonzis.ex;

public class Ex04_2D_array {
	public static void main(String[] args) {
		/*
		 * 고정형 2차원 배열
		 * 	1. 행과 열이 고정되어 있는 2차원 배열
		 * 	2. 선언 방법
		 *		int[][] arr = new int[3][4];		// 3행 4열
		 *	3. 초기화 방법
		 *		int[][] arr = new int[][]{{1,2,3,4},{5,6,7,8},{9,10,11,12}};
		 *		int[][] arr = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
		 */
		
		
		// 2행 3열 정수형 배열
		int[][] arr = {
				{1,2,3},
				{4,5,6}
		};
		
		
		// i : 행, j : 열
		for(int i=0; i<arr.length; i++) {
			for(int j=0; j<arr[i].length; j++) {
				System.out.print(arr[i][j] + "\t");
			}
			System.out.println();
		}
		
		
		
		
		
		
		
		
	}
}

'JAVA > chapter05_array' 카테고리의 다른 글

Test . array  (0) 2023.05.26
chapter05 : 2D_array  (0) 2023.05.26
chapter03 : String_array  (0) 2023.05.26
chapter02 : for_each  (0) 2023.05.26
chapter01 : primitive_array  (0) 2023.05.26