Array Utility class: Arrays

Source: Internet
Author: User

In the Java.util package, there is a utility class for manipulating arrays: Java.util.Arrays. It provides a series of static methods. See Javaapi for details.

 Packagepackage14_7;Importjava.util.Arrays; Public classarray_2 { Public Static voidTeststringarray () {string[] S1={"Tom", "Jack", "Mike", "Tom2"}; string[] S2={"Tom", "Jack", "Mike", "Tom2"}; System.out.println ("S1 and s2 comparison" +arrays.equals (S1, S2));//trueArrays.sort (S1);//sort S1 for an arraySystem.out.println ("S1 and S2 two times comparison" +arrays.equals (S1, S2));//falseSystem.out.println ("Jack position in S1 array" +arrays.binarysearch (S1, "Jack")); System.out.println ("Jack in the S2 array position" +arrays.binarysearch (S2, "Jack")); System.out.println ("S1" +arrays.tostring (S1)); }     Public Static voidMain (string[] args) {Teststringarray (); }}

S1 and S2 Compare true
S1 and S2 two times comparison false
Jack in the S1 array position 0
Jack in the S2 array position 1
S1[jack, Mike, Tom, Tom2]

Array Utility class: 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.