This content has been marked as final. Show 9 replies
would your code work if you initialized test so:
> public class GlobalCache
extends Hashtable<Integer ,Hashtable<Integer,? extends InfoBean>>
GlobalCache global = GlobalCache.instance();
Hashtable test = global.get(123); // (1)
test.put(666, new InfoBean()); // (2)
i believe that this way you could still put other classes that have InfoBean as their superclass into that hashtable...
Hashtable<Integer, InfoBean> test = global.get(123);
or evenmore, could you define GlobalChace to extend Hastable <Integer, Hashtable<Integer, InfoBean>>
PS! i've never used generics, so i may be completely on the wrong tracks.
Not sufienciente that declares that your class extends another with the generic should explicitly indicate which types are the ones who accept at the time of instantiating your object cache put you an example of my code
Hashtable<String,Atributo> salida=new Hashtable<String,Atributo>();
Atributo elemento = new Atributo();
if u try put another object (try put "3") u have an error message:
AtributoAD.java:50: cannot find symbol
symbol : method put(java.lang.String,String)
location: class java.util.Hashtable<java.lang.String,Atributo>
I hope it has been for Aid
Edited by: Edson_Chavez on Oct 30, 2007 6:36 PM
ejp wrote:well 2 years eight months late, i find this post at google looking for similar problem at generics, maybe someone find too and now this post HAVE a reply to help ;)
I hope it has been for AidWell it might have been 2 years and eight months ago when the discussion was happening...
i dont know why my screen name has change :( i login to reply and tell me "Please select Screen Name" and when i write "Edson_Chavez" they said "No disponible" :s