Here you can find the source of toHashMap(ArrayList
list
and values are sequential integers starting at beginId
static public HashMap<String, Integer> toHashMap(ArrayList<String> list, int beginId)
//package com.java2s; import java.util.ArrayList; import java.util.HashMap; public class Main { /** @return HashMap whose keys are strings from <code>list</code> and values are sequential integers starting at <code>beginId</code> */ static public HashMap<String, Integer> toHashMap(ArrayList<String> list, int beginId) { HashMap<String, Integer> map = new HashMap<String, Integer>(list.size()); for (int i = 0; i < list.size(); i++) map.put(list.get(i), i + beginId); return map; }/*from w w w . ja v a 2s . com*/ }