Created
December 16, 2016 11:47
-
-
Save begetan/45118ec0cf6b8907b8b9855af5cad6b0 to your computer and use it in GitHub Desktop.
Test Java random filling of Set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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