![]() |
Re: Generics for a multiplevalue hashmap
Thanks for all your replies.
I have done this public class MultipleValueHashMap<T, U> implements Map<T, java.util.List<U>> { I want to implement Map rather than extend HashMap as per Josh Bloch's Effective Java item 16. http://java.sun.com/docs/books/effective/toc.html So I do not want to do this. public class MM2<T,U> extends HashMap<T, List<U>> { } Thanks for all your help. I will look into some of the other answers later in the week. Many thanks Richard |
Re: Generics for a multiplevalue hashmap
On 7/19/2011 4:32 PM, Richard wrote:
> I have done this > > public class MultipleValueHashMap<T, U> implements Map<T, java.util.List<U>> { > > I want to implement Map rather than extend HashMap as per Josh Bloch's Effective Java item 16. http://java.sun.com/docs/books/effective/toc.html > > So I do not want to do this. > public class MM2<T,U> extends HashMap<T, List<U>> { > } Note the word "favor". You should evaluate not just choose without thinking. Arne |
Re: Generics for a multiplevalue hashmap
Arne Vajhøj wrote:
> Richard wrote: >> I have done this > >> public class MultipleValueHashMap<T, U> * implements Map<T, java.util.List<U>> *{ > >> I want to implement Map rather than extend HashMap as per Josh Bloch's Effective Java item 16.http://java.sun.com/docs/books/effective/toc.html > >> So I do not want to do this. >> public class MM2<T,U> *extends HashMap<T, List<U>> * { >> } > > Note the word "favor". > > You should evaluate not just choose without thinking. At the very least, consider extending java.util.AbstractMap<K,V>. -- Lew |
| All times are GMT. The time now is 03:03 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.