首页 > 其他 > 详细

Set笔记

时间:2014-09-13 09:25:55      阅读:298      评论:0      收藏:0      [点我收藏+]

import com.hephec01;

public class HashSetTest{

public static void main(String[] args){

Random rand=new Random();

Set<String> hash=new HashSet<String>();

for(int i=0;i<10000;i++){

hash.add(rand.nextInt(30));

System.out.println(hash);

}

}

}

//HashSet使用的是散列技术

//测试输出数据并没有10000个

import com.hephec02;

public class TreeSetTest{

public static void main(String[] args){

Random rand=new Random();

Set<String> tree=new TreeSet<String>();

for(int i=0;i<10000;i++){

tree.add(rand.nextInt(30));

System.out.println(hash);

}

}

}

//TreeSet将元素存储在红黑树中

//测试输出数据并没有10000个

Set笔记

原文:http://blog.csdn.net/hephec/article/details/39238057

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!