fork(1) 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. private static Random random = new Random();
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. int[] map = new int[7];
  14. for (int i = 0; i < 7; i++) {
  15. map[i] = 0;
  16. }
  17. for (int i = 0; i < 10000000; i++) {
  18. random.setSeed(System.nanoTime());
  19. map[random.nextInt(7)]++;
  20. }
  21. for (int i = 0; i < 7; i++) {
  22. System.out.println(i + ": " + map[i]);
  23. }
  24. }
  25. }
Success #stdin #stdout 3.4s 320704KB
stdin
Standard input is empty
stdout
0: 1430877
1: 1429684
2: 1427559
3: 1428928
4: 1426981
5: 1428310
6: 1427661