Creating a Map That Retains Order-of-Insertion

Map map = new LinkedHashMap(); // Add some elements map.put("1", "value1"); map.put("2", "value2"); map.put("3", "value3"); map.put("2", "value4"); // List the entries for (Iterator it=map.keySet().iterator(); it.hasNext(); ) { Object key = it.next(); Object value = map.get(key); } // [1=value1, 2=value4, 3=value3]

Comments

7 Jan 2010 - 12:13pm by Anonymous (not verified)

this part

if (e.getValueIsAdjusting()) {
// The mouse button has not yet been released
}

has no sence.

by the way, thanks! nice code.

22 Feb 2010 - 6:35am by Washi (not verified)

Great Code, I appreciate it.

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.