Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #6291

Re: Generics for a multiplevalue hashmap

From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Generics for a multiplevalue hashmap
Date 2011-07-19 08:31 -0700
Organization A noiseless patient Spider
Message-ID <j047vt$3ri$1@dont-email.me> (permalink)
References <2f4c5543-ceef-4cdb-8ff7-b978f30766e0@glegroupsg2000goo.googlegroups.com> <4e257763$0$46572$c30e37c6@exi-reader.telstra.net>

Show all headers | View raw


On 7/19/2011 5:24 AM, Esmond Pitt wrote:
> On 19/07/2011 7:31 AM, Alexis Berry wrote:
>> public class MultipleValueHashMap<T, java.util.List<U>> implements
>> Map<T, java.util.List<U>> {
>
> public class MultipleValueHashMap<T, <L extends java.util.List<U>>>
> implements Map<T, L> ?


Well, this doesn't work for a couple of reasons.  First, in terms of 
syntax, you still have to declare U as a type parameter:

public class GenericTest<T, U, L extends List<U>>
         extends AbstractMap<T, List<U>> {

Secondly, "List" here is both an input and and output.  And going by 
PECS -- Producer Extends, Consumer Super -- you can't use just one.  So 
I think the default is just to try to get the right type there (List 
works) and be careful with your type declarations.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

Generics for a multiplevalue hashmap Alexis Berry <iamrichardjones@gmail.com> - 2011-07-18 14:31 -0700
  Re: Generics for a multiplevalue hashmap markspace <-@.> - 2011-07-18 14:40 -0700
  Re: Generics for a multiplevalue hashmap Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-18 21:00 -0300
  Re: Generics for a multiplevalue hashmap Arne Vajhøj <arne@vajhoej.dk> - 2011-07-18 23:01 -0400
  Re: Generics for a multiplevalue hashmap Roedy Green <see_website@mindprod.com.invalid> - 2011-07-19 03:59 -0700
  Re: Generics for a multiplevalue hashmap Esmond Pitt <esmond.pitt@bigpond.com> - 2011-07-19 22:24 +1000
    Re: Generics for a multiplevalue hashmap markspace <-@.> - 2011-07-19 08:31 -0700

csiph-web