Map的泛型运用

import java.util.*;
public class MapGeneric
{
	public static void main(String args[])
	{
		Map map=new HashMap();
		map.put("a", "aa");
		map.put("b", "bb");
		map.put("c", "cc");
		map.put("d", "dd");
		Set set=map.keySet();
		Iterator ite=set.iterator();
		while(ite.hasNext())
		{
			String str=ite.next();
			System.out.println(str+" = "+map.get(str));
		}
		System.out.println("-----------------------------------");
		Set> set1=map.entrySet();
		Iterator> i=set1.iterator();
		while(i.hasNext())
		{
			Map.Entry s=i.next();
			System.out.println(s.getKey()+" = "+s.getValue());
		}
	}
}

你可能感兴趣的:(java)