fork download
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. class NumeroAleatorio {
  7.  
  8. private static List<Integer> nuemors = new ArrayList<>();
  9. private static Random random;
  10.  
  11. public static void adNuemoros() {
  12. random = new Random();
  13. for (int i = 0; i < 7; i++) {
  14. if (i < 3) {
  15. nuemors.add(1);
  16. }else{
  17. Collections.shuffle(nuemors); // embaralha nos numero 1 no array.
  18. nuemors.add(random.nextInt(10)+5);
  19. }
  20. }
  21. System.out.println(nuemors.toString());
  22. }
  23.  
  24. public static void main(String[] args) {
  25. adNuemoros();
  26. }
  27.  
  28. }
  29.  
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
[1, 5, 6, 1, 1, 5, 14]