(String[] args)
| 6 | |
| 7 | public class ImperativeRandoms { |
| 8 | public static void main(String[] args) { |
| 9 | Random rand = new Random(47); |
| 10 | SortedSet<Integer> rints = new TreeSet<>(); |
| 11 | while(rints.size() < 7) { |
| 12 | int r = rand.nextInt(20); |
| 13 | if(r < 5) continue; |
| 14 | rints.add(r); |
| 15 | } |
| 16 | System.out.println(rints); |
| 17 | } |
| 18 | } |
| 19 | /* Output: |
| 20 | [7, 8, 9, 11, 13, 15, 18] |