1. 2 ์ฐจ์ ๋ฐฐ์ด ์ ์ธ ๋ฐฉ๋ฒ
2 ์ฐจ์ ๋ฐฐ์ด = { 1์ฐจ์ ๋ฐฐ์ด,
1์ฐจ์ ๋ฐฐ์ด,
1์ฐจ์ ๋ฐฐ์ด}
// 3 x 5 ํฌ๊ธฐ์ 2์ฐจ์์ผ๋ก ํํํ๊ธฐ
String[][] seats = new String[][] {
{"A1", "A2","A3","A4","A5"},
{"B1", "B2","B3","B4","B5"},
{"C1", "C2","C3","C4","C5"}
};
// ๋ฐ๋ก ์ด๊ธฐํ ์ํ ๋๋
String[][] seats2 = new String[3][5];
// B2์ ์ ๊ทผํ๋ ค๋ฉด?
System.out.println(seats[1][1]);
//C5์ ์ ๊ทผํ๋ ค๋ฉด?
System.out.println(seats[2][4]);
2. ๊ฐ ํ ๋ง๋ค ๊ธธ์ด๊ฐ ๋ค๋ฅธ 2 ์ฐจ์ ๋ฐฐ์ด
String[][] seats2 = {
{"A1", "A2","A3"},
{"B1", "B2","B3","B4"},
{"C1", "C2","C3","C4","C5"}
};
// A3 ์ ์ ๊ทผํ๋ ค๋ฉด?
System.out.println(seats2[0][2]);
// A5 ๊ฐ ์์ง๋ง ์ ๊ทผํ๋ ค๋ฉด? -> ์๋ฌ
//System.out.println(seats2[0][4]);
3. <์ฐธ๊ณ > 3 ์ฐจ์ ๋ฐฐ์ด (์ธ๋ก x ๊ฐ๋ก x ๋์ด)
3 ์ฐจ์ = {2 ์ฐจ์, 2 ์ฐจ์, 2 ์ฐจ์}
// 3์ฐจ์ ๋ฐฐ์ด ๋ง๋ค๊ธฐ (์ธ๋ก x ๊ฐ๋ก x ๋์ด)
String[][][] marray = new String[][][] {
{{}, {}, {}},
{{}, {}, {}},
{{}, {}, {}}
};
0