Here you can find the source of listToMap(List> list)
Parameter | Description |
---|---|
list | the list |
public static <T> Map<T, T> listToMap(List<List<T>> list)
//package com.java2s; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class Main { /**/* ww w .j a va2s . co m*/ * Converts a list of two element lists (key, value) into a map. * * @param list the list * @return a map */ public static <T> Map<T, T> listToMap(List<List<T>> list) { Map<T, T> map = new HashMap<T, T>(list.size()); Iterator<List<T>> i = list.iterator(); while (i.hasNext()) { List<T> l = i.next(); map.put(l.get(0), l.get(1)); } return map; } }