How does java define a two-dimensional array ?, Java defines two-dimensional arrays

Source: Internet
Author: User

How does java define a two-dimensional array ?, Java defines two-dimensional arrays

Java uses [] [] to define two-dimensional arrays and can also be initialized at the same time.

Below are some examples
Float [] [] numthree; // defines a float-type 2-dimensional array
Numthree = new float [5] [5]; // allocate space for five rows and five columns
Numthree [0] [0] = 1.1f; // use the subscript index to access 1 row and 1 column = 1.1
Long [] [] numfive = new long [5] []; // defines an irregular long array.
Numfive [0] = new long [5]; // allocate 5 columns to 1st rows
// Define an array of the double type and assign values to the space of three rows and three columns.
Double [] [] numsix = {1.111D, 2.222D, 3.333D}, {4.444D, 5.555D, 6.666D }};

Int [] [] numseven = new int [] [] {10, 20, 30}, {40, 50}, {60 }};

Related Article

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.