Java 2차원 배열

1 개요[ | ]

Java 2차원 배열
자바 2차원 배열
import java.util.Arrays;
public class MyClass {
    public static void main(String args[]) {
        int a[][] = {{1,2,3}, {4,5,6}};
        System.out.println( Arrays.deepToString(a) );
        // [[1, 2, 3], [4, 5, 6]]
    }
}
import java.util.Arrays;
public class MyClass {
    public static void main(String args[]) {
        int a[][] = {{1,2,3}, {4,5,6}};
        for(int i=0; i<a.length; i++) {
            System.out.println( Arrays.toString(a[i]) );
            // [1, 2, 3]
            // [4, 5, 6]
        }
    }
}
public class MyClass {
    public static void main(String args[]) {
        int a[][] = {{1,2,3}, {4,5,6}};
        for(int i=0; i<a.length; i++) {
            for(int j=0; j<a[0].length; j++) {
                System.out.format("%d ", a[i][j] );
                // 1 2 3 
                // 4 5 6   
            }
            System.out.println();
        }
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}