informaticage

Random no repeat

Dec 3rd, 2021
646
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data