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

时间:2017-08-18 12:26:23   收藏:0   阅读:989

@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/remember-forget/p/7388903.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!