* Initialization of three-dimensional arrays and traversal of three for loops

Source: Internet
Author: User

Package com.chongrui.test;

/*
* Initialization and traversal of three-dimensional arrays
* */


public class Test {

public static void Main (string[] args) {

int A[][][]=new int[][][]{
{{1,2,3},{4,5,6}},
{{8,9,10},{11,12,13}},
{{14,15,16},{17,18,19,20}},

};

for (int i=0;i<a.length;i++) {
System.out.println ("the" + (i+1) + "Elements of a three-dimensional array is a" +a[0].length+ "dimension array, as follows:");
for (int j=0;j<a[i].length;j++) {//iterate through each element in the array,
for (int k=0;k<a[0][0].length;k++) {
System.out.print (a[i][j][k]+ "\ t");//The output of each element in the array
}
System.out.println ("");
}



}


}
}

The 1th element of a three-dimensional array is a 2-dimensional array with the following contents:
123
55W
The 2nd element of a three-dimensional array is a 2-dimensional array with the following contents:
8910
111213
The 3rd element of a three-dimensional array is a 2-dimensional array with the following contents:
141516
171819

* Initialization of three-dimensional arrays and traversal of three for loops

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.