package day04;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
/**
* 集合的排序
* @author Administrator
*
*/
public class SortCollection {
public static void main(String[] args) {
List<Integer> c = new ArrayList<Integer>();
Random random = new Random();
for(int i=0;i<10;i++) {
c.add(random.nextInt(100));
}
System.out.println(c);
/*
* 通过Collections这个集合的工具类
* 我们可以对List集合进行自然排序
*/
Collections.sort(c);
System.out.println(c);
}
}
Java——集合的排序,通过Collections这个集合的工具类
最新推荐文章于 2024-03-01 23:31:58 发布