Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; public class Main { public static ArrayList<String> getHashMap2(HashMap<String, Integer> hm) { ArrayList<String> a = new ArrayList<String>(); Set<Map.Entry<String, Integer>> s = hm.entrySet(); Iterator<Map.Entry<String, Integer>> it = s.iterator(); while (it.hasNext()) { Map.Entry<String, Integer> m = (Map.Entry<String, Integer>) it.next(); a.add(m.getKey() + "\t" + m.getValue()); } return a; } }