Map<String, String> mapServlet = new HashMap<String, String>();
System.out.println("迭代方法一"); for( Object key:mapServlet.keySet()){ System.out.println( key ); System.out.println(mapServlet.get(key)); } System.out.println("迭代方法二"); for( Object value: mapServlet.values()){ System.out.println(value); } System.out.println("迭代方法三"); for(Iterator iterator = mapServlet.entrySet().iterator();iterator.hasNext();){ Object keyObject = iterator.next(); System.out.println(keyObject); } System.out.println("迭代方法四"); for(Iterator iterator = mapServlet.entrySet().iterator();iterator.hasNext();){ Map.Entry entry = (Entry)iterator.next(); System.out.println(entry.getKey()); System.out.println(entry.getValue()); }