import java.util.*; import javax.swing.*; class RandFunction { public static void main(String[] args) { Set<Integer> s = new HashSet<Integer>(); int m=0; String scount = JOptionPane.showInputDialog(null,"Enter random number limit"); int count=Integer.parseInt(scount); Integer[] f = new Integer[count]; while(m<count) { Random r = new Random(); int i = r.nextInt(count); boolean valid = s.add(i); if(valid) { f[m]=i; m++; } } for(int k=0;k<count;k++) { System.out.println(f[k]); } } }