Timeline for Why define a Java object using interface (e.g. Map) rather than implementation (HashMap)
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 13, 2018 at 6:24 | comment | added | bcorso |
@JohnMercier yeah, that would be my understanding too. My comment was to clarify the text, which currently makes it seem like LinkedHashMap implements SortedMap .
|
|
Jul 11, 2018 at 13:54 | comment | added | John Mercier |
@bcorso this is because LinkedHashMap is ordered not sorted.
|
|
Aug 8, 2014 at 18:55 | comment | added | bcorso |
Actually, a LinkedHashMap doesn't implement SortedMap . The only subclasses of SortedMap are ConcurrentSkipListMap and TreeMap .
|
|
Mar 7, 2014 at 13:41 | history | edited | Neil | CC BY-SA 3.0 |
added 133 characters in body
|
Mar 7, 2014 at 13:33 | history | edited | Neil | CC BY-SA 3.0 |
added 7 characters in body
|
Mar 7, 2014 at 10:27 | history | edited | Neil | CC BY-SA 3.0 |
added 76 characters in body
|
Mar 7, 2014 at 10:26 | comment | added | Neil | @Arian Ah I see what you mean. True, better SortedMap since that doesn't force an implementation. I'll make the proper adjustments. | |
Mar 6, 2014 at 20:43 | comment | added | Cephalopod | No, SortedMap is not an implementation, that's exactly the point. It is the interface for maps that sort by key. | |
Mar 6, 2014 at 13:44 | comment | added | Neil |
@Arian SortedMap is one of several implementations which deal with ordering. That's besides the point. TreeMap also orders items according to the key's implementation of Comparable or given a Comparator interface.
|
|
Mar 5, 2014 at 9:30 | comment | added | Cephalopod |
When you need a map that is sorted, the parameter type should be SortedMap , not TreeMap .
|
|
Jan 27, 2014 at 18:00 | vote | accept | Suman | ||
Jan 27, 2014 at 17:08 | vote | accept | Suman | ||
Jan 27, 2014 at 17:08 | |||||
Jan 27, 2014 at 16:56 | history | answered | Neil | CC BY-SA 3.0 |