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