An overview of java-arrays

Source: Internet
Author: User
Tags array definition array length

Array definition: An array is a collection of data of the same type, which describes a combination of several data of the same type, each of which is called an array element, and each array element can be

A subscript to access them.

Four basic points of the array:

1, fixed length, once created its length is immutable

2, its element type must be the same type, no blending type is allowed

3, the element in the array is any data type, including the base data type and the reference data type

4, array variables are reference types, arrays can also be considered as objects, each element of the array is equivalent to the object's member variable, the array itself is an object, the object in Java is in the heap

So the array itself is in the heap, regardless of whether it holds the original type or other object types.

The subscript legal interval for an array is [0,arr,length-1]

Copy of array: system,arraycopy (source array, starting from where, target array, starting from, sticking a few)

Ordering of arrays: Arrays.sort (sorted array)

Binary lookup: Arrays.binarysearch (that array, what elements in the array)

Padding array: Arrays.fill (a,2,4,10). Replace the element with index 2 through 4 in array a with 10

Get array Length: array. length. A[0].length in a two-dimensional array represents the length of the first array in a two-dimensional array

Array traversal: You can use a for loop or for nested loops (two-dimensional arrays)

An overview of java-arrays

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.