Here you can find the source of printMap(Map
System.out.println
, both keys and values are printed.
Parameter | Description |
---|---|
map | Map which contents is to be printed. |
@SuppressWarnings("rawtypes") public static void printMap(Map<Object, Object> map)
//package com.java2s; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Main { /**/*from ww w . j a va 2s. co m*/ * To print given maps content with <code>System.out.println</code>, both * keys and values are printed. * * @param map * Map which contents is to be printed. */ @SuppressWarnings("rawtypes") public static void printMap(Map<Object, Object> map) { Set<Entry<Object, Object>> s = map.entrySet(); Iterator<Entry<Object, Object>> it = s.iterator(); while (it.hasNext()) { Map.Entry entry = it.next(); Object key = entry.getKey(); Object value = entry.getValue(); System.out.println(key.toString() + " => " + value.toString()); } } }