• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Question in Generic Methods  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following code:


Compiling the above code gives following error:
Test2.java:19: process(java.util.Map<java.lang.String,java.util.HashMap<java.lang.Long,? extends core.Fruit>>) in core.Test2 cannot be applied to (java.util.Map<java.lang.String,java.util.HashMap<java.lang.Long,core.Fruit>>)
process(buildingblocksmap);
^
1 error
Can anybody please explain the reason of this error?
 
security forum advocate
Ranch Hand
Posts: 216
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The process method signature needs to be changed to this.

 
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sai Hegde wrote:The process method signature needs to be changed to this.




got it wrong first, but yes that works....

 
Sai Hegde
security forum advocate
Ranch Hand
Posts: 216
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are confusing the compiler here...

Try this -
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sai, you're right, the original method definition works alright
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!