分享java带来的快乐

我喜欢java新东西

List Set Map 数组之间转换

1.list转化成数组

List<String> strlist = new ArrayList<String>();
String[] array=(String[]) strlist.toArray(new String[strlist.size()]);

2.set转化成list

Set BoardSet=new HashSet<Board>();
this.boardList = new ArrayList<Board>(BoardSet);

3.list转化成set

List list = new ArrayList(new Hashset());
Set set = new HashSet(list);
---------------------------------------------------------------


List list = Arrays.asList(array); //数组转化成list

list = new LinkedList(Arrays.asList(array));

Set set = new HashSet(Arrays.asList(array));

4.将map转化成数组

Map parent = new HashMap<String, String>();

Set set = parent.entrySet();

posted on 2011-10-09 17:19 强强 阅读(561) 评论(0)  编辑  收藏 所属分类: Java


只有注册用户登录后才能发表评论。


网站导航: