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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Random random = new Random();
  13. long[] longArray = new long[5000000];
  14. for (int i = 0; i < 5000000; i++) {
  15. longArray[i] = random.nextLong();
  16. }
  17. long time = System.currentTimeMillis();
  18. Arrays.sort(longArray);
  19. System.out.println("For long array " + (System.currentTimeMillis() - time));
  20.  
  21. double[] objArray = new double[5000000];
  22. for (int i = 0; i < 5000000; i++) {
  23. objArray[i] = random.nextDouble() * 5000000;
  24. }
  25. time = System.currentTimeMillis();
  26. Arrays.sort(objArray);
  27. System.out.println("For dbl array " + (System.currentTimeMillis() - time));
  28.  
  29. int[] intArray = new int[5000000];
  30. for (int i = 0; i < 5000000; i++) {
  31. intArray[i] = random.nextInt(5000000);
  32. }
  33. time = System.currentTimeMillis();
  34. Arrays.sort(intArray);
  35. System.out.println("For int array " + (System.currentTimeMillis() - time));
  36. }
  37. }
Success #stdin #stdout 3.69s 380608KB
stdin
Standard input is empty
stdout
For long array 1023
For dbl array 848
For int array 673