import java.util.TreeSet; public class Lotto { public static void main(String[] args) { for (int x : lottoNums()) System.out.print(x + " "); } public static TreeSet lottoNums() { TreeSet r = new TreeSet(); while (r.size() < 6) r.add((int) (Math.random() * 45 + 1)); return r; } }