Application of arrays class in Java

Source: Internet
Author: User

The Java.util.Arrays class makes it easy to manipulate an array, and all of the methods it provides are static. Has the following features:

1. Elements inside the direct output array (Java Core volume- array is a data structure )

2 Assigning a value to an array: through the fill method.

2 sorting an array: By the sort method , in ascending order.

2 Comparing arrays: compares the values of elements in an array by the Equals method.

2 Finding array elements: The binarysearch method can be used to perform binary lookups of sorted arrays.

Arrays.fill () method;
Usage 1: Accepts 2 parameters
Arrays.fill (A1, value);
Note: A1 is an array variable, and value is the values of the element data type in a A1, which acts: each element in the fill A1 array is value
For example:
boolean[] A1 = new boolean[5];
Arrays.fill (a1,true);
Result a1[] = {True,true,true,true,true};

Usage 2: Accept 4 parameters: Fill out
For example:



The first parameter refers to an array of operations, the second and third refers to the insertion of a fourth parameter in an area of the array, the second parameter refers to the starting element subscript (including the subscript), the third parameter refers to the end subscript (without the subscript), note: The array subscript for Java starts with 0

Application of arrays class in Java

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.