Java tutorial
//package com.java2s; import java.util.Map; import java.util.Map.Entry; public class Main { public static String mapToString(Map<? extends Object, ? extends Object> result) { StringBuilder builder = new StringBuilder(); for (Entry<? extends Object, ? extends Object> productEntry : result.entrySet()) { builder.append(productEntry.getKey() + "\t" + productEntry.getValue() + "\n"); } return builder.toString(); } public static Number getValue(Map<? extends Object, ? extends Number> map, Object key, Class<?> clazz) { Number value = map.get(key); if (value == null) { if (clazz.equals(Double.class)) { value = 0.0; } else { value = 0; } } return value; } }