Created
June 1, 2014 17:50
-
-
Save AndrewHanes/f0bffbcdece48d6f5100 to your computer and use it in GitHub Desktop.
Random number picker
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 rand { | |
public static void main(String[] args) { | |
ArrayList<Integer> al = new ArrayList<Integer>(); | |
for(int i = 0; i < 10; ++i) { | |
al.add(i); | |
} | |
Random r = new Random(); | |
ArrayList<Integer> result = new ArrayList<Integer>(); | |
for(int i = 0; i < 5; ++i) { | |
int index = r.nextInt(al.size()); | |
result.add(al.remove(index)); | |
} | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment