Colluctions集合中的常用方法

阅读 40

2022-04-03


import java.util.*;

/*Colluction集合的常用方法:
sort:排序
reverse:倒序
shuffle:随机排序
* */
public class homework {
    public static void main(String[] args) {
        List<Integer> l=new ArrayList<Integer>();
        l.add(1);
        l.add(5);
        l.add(6);
        l.add(3);
        l.add(4);
        System.out.println(l);
        System.out.println("---------------------");
        Collections.sort(l);
        System.out.println(l);
        System.out.println("---------------------");
        Collections.reverse(l);
        System.out.println(l);
        System.out.println("---------------------");
        Collections.shuffle(l);
        System.out.println(l);
        
    }
}

 

精彩评论(0)

0 0 举报