日期:2014-05-20 浏览次数:20753 次
import java.util.HashMap; import java.util.List; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * User: admin * Date: 2011-9-26 * Time: 15:47:10 * To change this template use File | Settings | File Templates. */ public class MapDemo { public static void main(String[] args){ HashMap<Integer, List<String>> hm=new HashMap<Integer, List<String>>(); List<String> list1=new ArrayList<String>(); list1.add("a"); list1.add("b"); list1.add("c"); List<String> list2=new ArrayList<String>(); list2.add("d"); list2.add("e"); list2.add("f"); hm.put(1,list1); hm.put(2,list2); for(int i:hm.keySet()){ List<String> list=hm.get(i); System.out.println(list); } } }