import java.util.*; public class MainClass { public static void main(String args[]) { TreeMap map = new TreeMap(); map.put("one","1"); map.put("two","2"); map.put("three","3"); displayMap(map); } static void displayMap(TreeMap map) { Collection c = map.entrySet(); Iterator i = c.iterator(); while(i.hasNext()){ Object o = i.next(); System.out.print(o.toString()); } } }