Here you can find the source of toString(Map, ?> map)
public static String toString(Map<?, ?> map)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.Map; public class Main { public static String toString(Map<?, ?> map) { if (map == null) { return null; }//w w w . j av a2 s .com @SuppressWarnings("rawtypes") Iterator iter = map.entrySet().iterator(); StringBuffer sb = new StringBuffer(); while (iter.hasNext()) { @SuppressWarnings("rawtypes") Map.Entry entry = (Map.Entry) iter.next(); sb.append("(" + entry.getKey() + "," + entry.getValue() + ")\r\n"); } return sb.toString(); } }