Prev: Daylight Saving Shift
Next: The Nike Shox shoes were the product of a sixteen years of research in the Nike Labs. In the fall of 2000, the Nike Shox system was revealed to the world. Nike unveiled this top secret line of shoes to the world in 3 models, the Nike Shox R4 (runn
From: Wojtek on 3 Nov 2009 10:56 Lew wrote : > 'TimeZone' can easily be a map key, yes, even for a 'TreeMap'. No it cannot be used as a key. It does not have a 'compareTo' method. -- Wojtek :-)
From: Lew on 3 Nov 2009 11:57 Lew wrote : >> 'TimeZone' can easily be a map key, yes, even for a 'TreeMap'. > Wojtek wrote: > No it cannot be used as a key. It does not have a 'compareTo' method. > Yes, it can be used as a key! <http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html#TreeMap (java.util.Comparator)> The Javadocs are your friend. -- Lew
From: Eric Sosman on 3 Nov 2009 12:04 Wojtek wrote: > Lew wrote : >> 'TimeZone' can easily be a map key, yes, even for a 'TreeMap'. > > No it cannot be used as a key. It does not have a 'compareTo' method. It doesn't need one: You can construct a TreeMap with any Comparator you like. You're not limited to the "natural order" of the keys. See the `TreeMap(Comparator<? super K> comparator)' constructor. -- Eric.Sosman(a)sun.com
From: Wojtek on 3 Nov 2009 13:42 Lew wrote : > Lew wrote : >>> 'TimeZone' can easily be a map key, yes, even for a 'TreeMap'. >> > > Wojtek wrote: >> No it cannot be used as a key. It does not have a 'compareTo' method. >> > > Yes, it can be used as a key! > <http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html#TreeMap > (java.util.Comparator)> > > The Javadocs are your friend. Yes with a separate Comparator. However you cannot do: TreeMap<TimeZone,String> directly. -- Wojtek :-)
From: Lew on 3 Nov 2009 14:37 Lew wrote : >>>> 'TimeZone' can easily be a map key, yes, even for a 'TreeMap'. > Wojtek wrote: > >> No it cannot be used as a key. It does not have a 'compareTo' method. > Lew wrote: >> Yes, it can be used as a key! >> <http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html#TreeMap >> (java.util.Comparator)> > >> The Javadocs are your friend. > Wojtek wrote: > Yes with a separate Comparator. However you cannot do: > > TreeMap<TimeZone,String> > > directly. > Why doesn't Map <TimeZone, String> map = new TreeMap <TimeZone, String> ( new Comparator() { .... } ); work for you? -- Lew
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: Daylight Saving Shift Next: The Nike Shox shoes were the product of a sixteen years of research in the Nike Labs. In the fall of 2000, the Nike Shox system was revealed to the world. Nike unveiled this top secret line of shoes to the world in 3 models, the Nike Shox R4 (runn |