fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static ArrayList<Integer> makeSequence(int begin, int end) {
  11. ArrayList<Integer> ret = new ArrayList(end - begin + 1);
  12. for(int i = begin; i <= end; ret.add(i++));
  13. return ret;
  14. }
  15.  
  16. static void printFirst(ArrayList<Integer> col, int len) {
  17. for(int i = 0; i < len; i++)
  18. System.out.print(col.get(i) + ", ");
  19. System.out.println("");
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. final ArrayList<Integer> all = makeSequence(0, 1000);
  25. System.out.println("in order");
  26. printFirst(all, 15);
  27. Collections.shuffle(all);
  28. System.out.println("shuffle");
  29. printFirst(all, 15);
  30. Collections.shuffle(all);
  31. System.out.println("shuffle");
  32. printFirst(all, 15);
  33. System.out.println("obviously should be the same");
  34. printFirst(all, 15);
  35. Collections.shuffle(all);
  36. System.out.println("shuffle");
  37. printFirst(all, 15);
  38. Collections.shuffle(all);
  39. System.out.println("shuffle");
  40. printFirst(all, 15);
  41. }
  42. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
in order
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
shuffle
611, 147, 677, 287, 475, 126, 217, 165, 725, 479, 453, 286, 298, 206, 258, 
shuffle
825, 340, 549, 307, 831, 612, 55, 502, 844, 679, 96, 814, 764, 747, 366, 
obviously should be the same
825, 340, 549, 307, 831, 612, 55, 502, 844, 679, 96, 814, 764, 747, 366, 
shuffle
782, 791, 477, 978, 920, 533, 503, 703, 882, 70, 854, 630, 828, 177, 814, 
shuffle
774, 136, 89, 55, 298, 587, 871, 913, 706, 928, 51, 982, 458, 909, 104,