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 int randomInt(int low, int high)
  11. {
  12. double e;
  13. double x=Math.random();
  14. e=low+x*(high-low);
  15. return (int)e;
  16. }
  17.  
  18. public static int[] randomIntArray(int n)
  19. {
  20. int[] a=new int[n];
  21. for(int i=0;i<a.length;i++)
  22. {
  23. a[i]=randomInt(-5,15);//"-5&15 are the lower and upper bounds of the random number array
  24. }
  25. return a;
  26. }
  27.  
  28. public static void main (String[] args) throws java.lang.Exception
  29. {
  30. int[] array = randomIntArray(5);
  31. for(int i = 0; i < array.length; i++)
  32. {
  33. System.out.println(array[i]);
  34. }
  35. }
  36. }
Success #stdin #stdout 0.09s 320320KB
stdin
Standard input is empty
stdout
11
10
7
3
4