public class RandomDemo {
public static void main(String[] args) {
// 定义集合存储产生的随机数
TreeSet<Integer> ts = new TreeSet<Integer>();
while (ts.size() < 10) {
int a = (int)(Math.random()*10+1);
ts.add(a);
}
StringBuilder sb = new StringBuilder();
for (Integer i : ts) {
if (i<10) {
sb.append(i).append(",");
}
else{
sb.append(i);
}
}
String result = sb.toString();
System.out.println(result);
}
}