print Map to console - Java java.util

Java examples for java.util:Map Operation

Description

print Map to console

Demo Code


//package com.java2s;
import java.util.Iterator;

import java.util.Map;

public class Main {
    public static void printMap(Map map) {
        Iterator iter = map.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }/* w  w  w  .j  av a  2s . c om*/
    }
}

Related Tutorials