获取7个随机数
彩.票.....
public static void main(String[] args) { StringBuilder s = new StringBuilder(" "); int count = 0; while (true) { int x = new Random().nextInt(33); if (s.toString().contains(" "+x+" ")) { continue; } else { s.append(x).append(" "); } if (++count >= 7) { break; } } System.out.println(s); }