Tuesday, November 30, 2010

LinkedHashMap

If you have a HashMap in a particular order and want to make sure it gets maintained, use LinkedHashMap.


// LinkedHashMap remembers the order in which the items are added to the list,
// which preserves the sorting coming from the db
Map<String, List<TopSellerDO>> topSellersByCategoryMap = new LinkedHashMap<String, List<TopSellerDO>>();

No comments: