Map的Value值转换为List集合
生活随笔
收集整理的這篇文章主要介紹了
Map的Value值转换为List集合
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
不多廢話,直接看代碼,有注解
public class Map轉(zhuǎn)List {public static void main(String[] args) {//開辟空間HashMap<Integer,String> hashMap = new HashMap<Integer,String>();//存入數(shù)據(jù)hashMap.put(1,"張三");hashMap.put(2,"李四");hashMap.put(3,"王五");//使用Collection類型接收HashMap的Value值Collection<String> collection = hashMap.values();//把Collection對(duì)象作為參數(shù)傳入ArrayList構(gòu)造方法完成類型轉(zhuǎn)換ArrayList<String> arrayList = new ArrayList<String>(collection);//輸出測(cè)試System.out.println(arrayList.toString());} }總結(jié)
以上是生活随笔為你收集整理的Map的Value值转换为List集合的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 没装驱动怎么读U盘 电脑无法识别U盘的解
- 下一篇: 将数字字符串转换成逗号分隔的数字串,即从