Java basic syntax < six > array Arrays

Source: Internet
Author: User

Allow array length to be 0new element[0] array length of 0 and null different array copies allow one array variable to be copied to another array variable. At this point, two variables will refer to the same array: int[] ele1 = ele2;ele1[5] = 12; Now Ele2[5] is also 12 if you want to copy all the values of an array to a new array, use the CopyTo method of the Arrays class: int[] Copiedele = arrays.copyof (Ele1, Ele1.length); The 2nd parameter is the length of an array, which is typically used to increase the size of the arrays. command-line arguments each Java application has a main method with a string arg[] argument. This parameter indicates that the main method will accept a string array, which is the command-line argument. Java.util.Arrays1.2Static String toString (type[] a)5.0Returns a string containing the data elements in a, which are enclosed in parentheses and separated by commas. Parameter: An array of type int, long, short, Byte, Boolean, float, or double static type copyOf (type[] a,int length)6STAITC type copyOf (type[] a,int start,int end)6Returns an array with the same length as the type A, or a value parameter of start-end array element: An array of type int, long, short, Byte, Boolean, float, or double that contains this             The value end-terminating subscript does not contain this value, which may be greater than a.length, in which case the result is 0 or false. Length of the data element of the copy. The result is 0 or false if the length value is greater than a.length; otherwise, only the copy value of the preceding length data element in the array is static void sort (type[] a) Sorting parameters with an optimized fast sorting algorithm for arrays: An array of type int, long, short, Byte, Boolean, float, or double, static int BinarySearch (type[] A,type v) static int BinarySearch (type[] a,int start,int End,type v)6The binary search algorithm is used to find the value v. If the lookup succeeds, the corresponding subscript value is returned, otherwise a negative value of R is returned. -r-l is the position to be inserted in order to keep a as ordered v.             Parameter: An array of type int, long, short, Byte, Boolean, float, or double start subscript (containing this value) end subscript (does not contain this value)         V same value as a data element type static void Fill (type[] A type V) sets all data element values of the array to the V parameter: an array of type int, long, short, Byte, Boolean, float, or double V the same value as the data element type a static Boolean equals (Type[] a type[] b) If two arrays are the same size, and the same elements are equal, return true parameter A, a, type int, long, short, byte , Boolean, float, or double array of arrays a multi-dimensional array foreach requires two nested loops for fast printing of System.out.println (Arrays.deeptostring (a)); The irregular array of Java actually has no multidimensional array, and the multidimensional array is interpreted as an array of arrays.

Java basic syntax < six > array 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.