HashSet

来源:互联网 发布:ubuntu 支持中文 编辑:程序博客网 时间:2024/06/05 00:23

public class Test {

public static void main(String[] args) {    HashSet<Integer> set = new HashSet<>();    Random random = new Random();    int count = 0;    while (set.size() < 10) {        int i = random.nextInt(90) + 10;        System.out.println(count++ + "随机得到的数" + i);        set.add(i);    }    Iterator<Integer> it = set.iterator();    while (it.hasNext()) {        int i = it.next();        System.out.println(i);    }    System.out.println("已经放进去了" + set.size());}

}

0 0
原创粉丝点击