fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. private static final int COLUMNS = 5;
  12. private static final int TBL_RANGE = 30;
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. List<Integer> tbl = new ArrayList<>(TBL_RANGE);
  16. IntStream.rangeClosed(1, TBL_RANGE).forEach(tbl::add);
  17. int[] ns = new int[COLUMNS];
  18. Random random = new Random(System.currentTimeMillis());
  19. for (int i = 0; i < COLUMNS; i++) {
  20. ns[i] = tbl.remove(random.nextInt(TBL_RANGE - i));
  21. }
  22.  
  23. for (int n : ns) {
  24. System.out.println(n);
  25. }
  26. }
  27. }
Success #stdin #stdout 0.08s 711680KB
stdin
Standard input is empty
stdout
25
22
1
5
12