Java two-dimensional array

Source: Internet
Author: User
Two-dimensional array declaration and initialization of data
String [][]a={
{"1", "2", "3"},
{"4", "5", "6"}
};

The form of a one-dimensional array:
(1), int a[]; a = new int[5]; equivalent to int a[] = new INT[5];
(2), int[] A; a = new int[5]; Equivalent to int[] A = new int[5];

Two-dimensional arrays:
int a[][] = {{3,4,5,6}, {7,8,9}}; a two-dimensional array can be seen as an array of elements.
The Declaration and initialization of multidimensional arrays in Java should be in order from high to low dimensions, such as:
Method (1);
int a[][] = new int[3][];
A[0] = new INT[2];
A[1] = new INT[4];
A[2] = new int[3];//correct
int t[][] = new int[][4];//illegal
Method (2);
int a[][] = new int[3][5];//Correct, assign a two-dimensional array of three rows and five columns.

Java two-dimensional array

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.