Advertisement
informaticage

Random no repeat

Dec 3rd, 2021
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.27 KB | None | 0 0
  1. import java.util.*;
  2. public class MyClass {
  3.     public static void main(String args[]) {
  4.       Set<Integer> s = new TreeSet<Integer>();
  5.      
  6.       while(s.size() != 30) {
  7.           s.add(new Random().nextInt(100));
  8.       }
  9.      
  10.       System.out.println(s);
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement