print Map for each of its key value pair - Java java.util

Java examples for java.util:Map Value

Description

print Map for each of its key value pair

Demo Code


//package com.java2s;

import java.util.Iterator;
import java.util.Map;

public class Main {
    public static String printMap(Map map) {
        StringBuffer buf = new StringBuffer();
        Iterator itKey = map.keySet().iterator();
        while (itKey.hasNext()) {
            String key = (String) itKey.next();
            buf.append(key + "=" + map.get(key) + ",");
        }// www .  j  a va 2  s  .c om
        return buf.toString();
    }
}

Related Tutorials