Java examples for java.util:List Convert
Convert map to List
//package com.java2s; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Main { public static <K, T> List<T> map2List(Map<K, T> mapData) { List<T> list = null; if (!isMapNull(mapData)) { Set<Entry<K, T>> keySet = mapData.entrySet(); Iterator<Entry<K, T>> iter = keySet.iterator(); list = new ArrayList<T>(); while (iter.hasNext()) { Map.Entry<K, T> value = iter.next(); list.add(value.getValue()); }// ww w .j ava 2 s . c om } return list; } public static <K, V> boolean isMapNull(Map<K, V> mapData) { if (mapData != null && mapData.size() != 0) { return false; } return true; } }