package day0226;
/**
* 개선된 for를 사용하여 배열의 모든방 출력
*/
public class TestFor {
public TestFor(){
int[] arr1={10,20,30,40,50};
System.out.println("일차원배열출력");
for(int i : arr1){
System.out.print(i+" ");
}//for
System.out.println("\n------------------------");
int[][] arr2={{1,2,3,4,5,6},{7,8,9,10,11,12}};
System.out.println("이차원 배열의 출력");
for(int[] a1 : arr2){ //이차원 배열의 한행을 일차원 배열에 할당
for(int i : a1){ //일차원 배열 방 하나의 값을 변수에 할당
System.out.print(i+" ");
}//for
System.out.println("행끝");
}//for
System.out.println("------------------------");
int[][][] arr3={{{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}}};
System.out.println("삼차원 배열의 출력");
for(int[][] a2 : arr3){ //삼차원배열의 한면을 이차원 배열에 할당
for(int[] a1 : a2){ //이차원 배열의 한행을 일차원 배열에 할당
for(int i : a1){ //일차원 배열 방의 값을 변수에 할당
System.out.print(i+" ");
}//for
System.out.println("행끝");
}//for
System.out.println("면끝");
}//for
System.out.println("----------------------------------");
int year=1984;
String[] zodiac={"원숭이","닭","개","돼지","쥐","소","호랑이","토끼","용","뱀","말","양"};
System.out.println(year + "년에 태어난 당신은 " +zodiac[year%12]+"띠입니다.");
}//TestFor
public static void main(String[] args) {
new TestFor();
}//main
}//class