Wednesday, 9 January 2013

Sorting a Map by its keys in Java

 
The key is to use TreeMap or convert the HashMap to TreeMap as done below. 
 
Map<String, String> map = new HashMap<String, String>();        
Map<String, String> treeMap = new TreeMap<String, String>(map);

No comments:

Post a Comment