fork(1) download
  1. import java.util.*;
  2. import java.lang.Math;
  3.  
  4. class HelloWorld {
  5. public static void main (String[] args) {
  6. ArrayList<Integer> lista = new ArrayList<>();
  7. for (int i = 0; i < 50; i++) {
  8. lista.add(i);
  9. }
  10. lista = seleciona(lista);
  11. for (int i = 0; i < 50; i++) {
  12. System.out.println(lista.get(i));
  13. }
  14. }
  15. public static ArrayList<Integer> seleciona(ArrayList<Integer> arraylist) {
  16. Random rnd = new Random();
  17. ArrayList<Integer> temp = new ArrayList<>(arraylist.size());
  18. for (int i = 0; i < arraylist.size(); i++) {
  19. temp.add(arraylist.get(rnd.nextInt(arraylist.size())));
  20. }
  21. return temp;
  22. }
  23. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
18
10
11
46
6
23
7
34
27
45
5
6
2
19
19
17
38
41
34
24
45
25
14
2
27
17
20
9
38
20
23
39
34
49
17
47
45
14
39
42
2
13
9
30
45
28
3
7
33
39