OnJava8-Examples/holding/SetOfInteger.java
2015-05-29 14:18:51 -07:00

16 lines
478 B
Java

//: holding/SetOfInteger.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
public class SetOfInteger {
public static void main(String[] args) {
Random rand = new Random(47);
Set<Integer> intset = new HashSet<>();
for(int i = 0; i < 10000; i++)
intset.add(rand.nextInt(30));
System.out.println(intset);
}
} /* Output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28]
*///:~