首页 > 其他分享 >集合与数组的两个工具类Collections 和Arrays

集合与数组的两个工具类Collections 和Arrays

时间:2022-12-30 09:33:51浏览次数:38  
标签:Arrays System scoreList Collections 数组 println out

public class Collections01 {
//    Arrays.deepEquals 深入到堆空间比较各个值
//     * Arrays.asList     快速生成一个集合
    @Test
     public void arraysTest(){
        List<String> list = Arrays.asList("张三", "李四", "王五");
        System.out.println(list);

        Integer[] ints1 = {110, 120, 130, 140};
        Integer[] ints2 = {110, 120, 130, 140};
        System.out.println(ints1 == ints2);
        System.out.println(Arrays.deepEquals(ints1, ints2));
    }
    @Test
    public void collectionsTest(){
//        max min
//     * reverse(倒存数据) shuffle(洗牌数据)
        List<Integer> scoreList = Arrays.asList(750, 740, 734, 760);
        Integer max = Collections.max(scoreList);
        System.out.println("max = " + max);

//        Collections.min();

        System.out.println("执行方法之前:" + scoreList);
        //        将集合中的数据倒着存放
        Collections.reverse(scoreList);
        System.out.println(scoreList);
        //        将集合中的数据 洗牌
        Collections.shuffle(scoreList);
        System.out.println(scoreList);

    }
}

 

标签:Arrays,System,scoreList,Collections,数组,println,out
From: https://www.cnblogs.com/p1121/p/17014073.html

相关文章