Here you can find the source of toString(Map
public static String toString(Map<String, String> m)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { private static final String K_V_SEPARATOR = "=>"; public static String toString(Map<String, String> m) { if (m.isEmpty()) { return ""; }/* w w w. j a v a 2 s . c om*/ StringBuilder sb = new StringBuilder(); int n = m.size(); for (String key : m.keySet()) { sb.append("\"" + key + "\"" + K_V_SEPARATOR + "\"" + m.get(key) + "\""); if (n > 1) { sb.append(", "); n--; } } return sb.toString(); } }