码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-12-06 14:43:38      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:aci   转换   order   put   oar   str   code   www.   row   

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[]

标签:aci   转换   order   put   oar   str   code   www.   row   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!