Java tutorial
//package com.java2s; /* This file is part of leafdigital util. util is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. util is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with util. If not, see <http://www.gnu.org/licenses/>. Copyright 2011 Samuel Marshall. */ import java.util.*; public class Main { /** * Convert the given map to a string. * @param m Any map to display * @return A string (multi-line) containing a view of the desired map */ public static <A, B> String toString(Map<A, B> m) { StringBuffer sb = new StringBuffer(); sb.append("[\n"); for (A key : m.keySet()) { sb.append(" " + key + " => " + m.get(key) + "\n"); } sb.append("]"); return sb.toString(); } }