• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generics Question: Map and Map.Entry

 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the Map class and calling the entrySet() method. Its defined


I tried to call it like so


I am using Java 1.5.0_22 and Eclipse 3.2.2. It won't let me type this. It insists on having

Set<? extends Map.Entry<? extends IProperty,? extends String>> properties = propHolder.getProperties().entrySet();

This does not make sense to me. Is this a compiler or Eclipse error? I haven't manually compiled Java in so long, I figured it be faster for me to ask than to try and manually invoke the java compiler. I know Eclipse uses its own internal compiler for identifying errors and debugging sessions. I can't figure out why this should not be allowed.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lets suppose we have two classes: Then our Map could contain Map.Entry<C1, String> and Map.Entry<C2, String>. My guess is that this is not the same Map.Entries, that's why you need to put Set<? extends Map.Entry>.
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think so. Map.Entry<C1,String> is not the same as Map.Entry<C2,String>. Besides, the Map.Entry is defined in the Map method, so there is no choice between the two.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic