Java Map Print printMap(Map map)

Here you can find the source of printMap(Map map)

Description

To print given maps content with System.out.println, both keys and values are printed.

License

Open Source License

Parameter

Parameter Description
map Map which contents is to be printed.

Declaration

@SuppressWarnings("rawtypes")
public static void printMap(Map<Object, Object> map) 

Method Source Code

//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());
        }
    }
}

Related

  1. printMap(Map mp)
  2. printMap(Map theMap)
  3. printMap(Map mp)
  4. printMap(Map map)
  5. printMap(Map map)
  6. printMap(Map map)
  7. printMap(Map map)
  8. printMap(Map map)
  9. printMap(Map map, int depth)