欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

数组工具类Arrays

程序员文章站 2024-03-05 23:39:43
...

public static String toString(数组)

public static void sort(数组)

import java.util.Arrays;
public class ArraysMethod {
    public static void main(String[] args){
        int[] arr = {1,9,9,9,0,1,2,3};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        String[] arr2 = {"aaa","xxx","ddd"};
        Arrays.sort(arr2);
        System.out.println(Arrays.toString(arr2));
    }
}

输出为

[0, 1, 1, 2, 3, 9, 9, 9]
[aaa, ddd, xxx]

相关标签: java