Java tutorial
//package com.java2s; import java.util.HashMap; public class Main { public static HashMap<String, String> errorMap = null; public static void addErrorMap(String mes) { if (errorMap == null) { errorMap = new HashMap<String, String>(); } if (errorMap.containsKey(mes)) { int count = Integer.valueOf(errorMap.get(mes)); errorMap.remove(mes); errorMap.put(mes, String.valueOf(++count)); } else { errorMap.put(mes, "1"); } } }