Java Learning Note 5

Source: Internet
Author: User

I remember there are three ways to define the array today, but I forgot to forget it,,,

Then look at the book, look it up online, sort out three ways

Method 1 (recommended, more indicative of array type) type[] Variable name = number of elements in the new type[array];  For example: int[] A = new int[10];  The array name, which refers to a, points to the first address of the array element.  Mode 2 (same as C language) type variable name [] = number of elements in the new type[array];  such as: int a[] = new INT[10];  Mode 3 defines the direct initialization of the type[] variable name = new type[]{comma-separated initialization value};  But it can be written as follows, there are two kinds: int[] a = {1,2,3,4};  Int[] A = new int[]{1,2,3,4}; where int[] a = new int[]{1,2,3,4}, the second square bracket cannot be added to the array length, because the number of elements is determined by the contents of the following curly braces.



Java Learning Note 5

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.