Here you can find the source of mapToList(Map
public static <K, V> List<List> mapToList(Map<K, V> map)
//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, V> List<List> mapToList(Map<K, V> map) { List<K> fields = new ArrayList<K>(); List<V> values = new ArrayList<V>(); Set<Entry<K, V>> set = map.entrySet(); Iterator<Entry<K, V>> iter = set.iterator(); while (iter.hasNext()) { Entry<K, V> entry = (Entry<K, V>) iter.next(); fields.add((K) entry.getKey()); values.add(entry.getValue()); }//from ww w. j av a 2 s. com List<List> result = new ArrayList<List>(); result.add(fields); result.add(values); return result; } }