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 r = new Random();
  13. int capacity = 10;
  14. int v[] = new int[capacity];
  15.  
  16. v[0] = 0;
  17. v[capacity - 1] = 15;
  18.  
  19. for (int i = 1, base = 10; i < v.length - 1; i++, base += 20) {
  20. v[i] = base + r.nextInt(11); //11 pois o ultimo índice é exclusive
  21. }
  22.  
  23. System.out.println(Arrays.toString(v));
  24. }
  25. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
[0, 10, 30, 50, 74, 93, 115, 133, 159, 15]