Skip to content

Instantly share code, notes, and snippets.

@begetan
Created December 16, 2016 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save begetan/45118ec0cf6b8907b8b9855af5cad6b0 to your computer and use it in GitHub Desktop.
Save begetan/45118ec0cf6b8907b8b9855af5cad6b0 to your computer and use it in GitHub Desktop.
Test Java random filling of Set
import java.util.*;
public class SetOfInteger {
public static void main(String[] args) {
Random rand = new Random(47);
Set<Integer> intset = new HashSet<Integer>();
for(int i = 0; i < 1000000000; i++)
intset.add(rand.nextInt(30));
System.out.println(intset);
}
} /* Output:
[15, 8, 23, 16, 7, 22, 9, 21, 6, 1, 29, 14, 24, 4, 19, 26, 11, 18, 3, 12, 27, 17, 2, 13, 28, 20, 25, 10, 5, 0]
*///:~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment