File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics Question: Map and Map.Entry

 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Andrey Kozhanov
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic