首页 > 编程语言 > 详细

Java中 map.values转换为list或者string[]

时间:2018-12-06 13:17:12      阅读:110      评论:0      收藏:0      [点我收藏+]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@Test
public void testMap2List() throws Exception{
    Map<String, String> map = new HashMap<String, String>();
    map.put("1""AA");
    map.put("2""BB");
    map.put("3""CC");
    map.put("4""DD");
 
    Collection<String> valueCollection = map.values();
    final int size = valueCollection.size();
 
    List<String> valueList = new ArrayList<String>(valueCollection);
 
    String[] valueArray = new String[size];
    map.values().toArray(valueArray);
}

原文地址   https://www.cnblogs.com/hqbhonker/p/5196359.html

Java中 map.values转换为list或者string[]

原文:https://www.cnblogs.com/ywb2018/p/10075872.html

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