22.2 Dアレイの使用


たじゅうはいれつ


  • スーパー2 Dアレイ

  • 平面(2 Dアレイ)または空間(3 Dアレイ)インプリメンテーションの使用
  • 2 Dアレイの例


    int[][] arr = {{1,2,3}, {4,5,6}}
    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.println(", \t" + arr[i].length);
    			System.out.println();
    		}
    	}
    }