19- array of tools commonly used method of Arrays

public static string toString (array): converts a string parameter array, use the default format: [element 1, element 2, ...]

public static void sort (array): sort the array in ascending order by default, the result is stored inside the original array.

1, if the array, the array size in ascending order according to the default.

2, if it is a string, the default alphabetical order.

3, if it is a custom type, then this custom class to have comparable or comparator interface support.

public class DemoArrays {
    public static void main(String[] args) {
        int[] charArray = {10,20,20};
        System.out.println(Arrays.toString(charArray));

        int[] charArray2 = {1,2,4,3,1,4,9,5};
        Arrays.sort(charArray2);
        System.out.println(Arrays.toString(charArray2));
    }
}

 

Published 74 original articles · won praise 4 · Views 4339

Guess you like

Origin blog.csdn.net/l0510402015/article/details/104092104