Java tutorial
import java.util.LinkedHashSet; import java.util.Random; import java.util.Set; public class Main { public static void main(String[] args) { Set<Integer> intSet = new LinkedHashSet<Integer>(); Random r = new Random(); while (intSet.size() <= 6) { intSet.add(r.nextInt(49)); } System.out.println(intSet); } }