Thinking in java学习笔记之set

   Random rand = new Random(47);
	   Set<Integer> set = new HashSet<Integer>();
	   for(int i=0;i<10000;i++){
		   set.add(rand.nextInt(30));
		   System.out.println(set);
	   }
//输出
/*

[8]
[5, 8]
[5, 8, 13]
[5, 8, 11, 13]
[1, 5, 8, 11, 13]
[1, 5, 8, 11, 13, 29]
[1, 5, 8, 11, 28, 13, 29]
[1, 20, 5, 8, 11, 28, 13, 29]
[1, 20, 5, 8, 11, 28, 12, 13, 29]
[1, 20, 5, 7, 8, 11, 28, 12, 13, 29]
[1, 18, 20, 5, 7, 8, 11, 28, 12, 13, 29]
[1, 18, 20, 5, 7, 8, 11, 28, 12, 13, 29]

*/

2.应用

原文地址:https://www.cnblogs.com/yansum/p/6080459.html