第1个回答 2017-10-24
java">import java.util.Iterator;
import java.util.Random;
import java.util.TreeSet;
public class Demo{
public static void main(String[] args) throws Exception {
TreeSet<Integer> ts = new TreeSet<Integer>();
for(int i = 0; i < 10; i++){
ts.add(new Random().nextInt(999));
}
for(Iterator<Integer> it = ts.iterator(); it.hasNext();){
System.out.println(it.next());
}
}
}本回答被提问者采纳