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

map 中values 返回列表,可以将器转化为list

@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); }

装载: http://www.cnblogs.com/hqbhonker/p/5196359.html

    原文作者:老鼬
    原文地址: https://blog.csdn.net/u010368839/article/details/78208167
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞