Created
November 13, 2018 02:42
-
-
Save Bharathbrothers/965fd4244e3137669379c1392ddf1f5a to your computer and use it in GitHub Desktop.
How to generate unique random numbers in Java?
This file contains hidden or 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
ArrayList<Integer> array = new ArrayList<>(4); | |
ArrayList<Integer> input = new ArrayList<>(4); | |
for(int i=0;i<10;i++){ | |
array.add(i); | |
} | |
Collections.shuffle(array); | |
for(int j=0;j<4;j++){ | |
input.add(array.get(j)); | |
} | |
// This generates unique numbers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment