• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Generic code help

 
Ranch Hand
Posts: 47
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is it because of '? extends ' instead of '? super' expression, the compiler wont let me add anything to the list. The code is from Khalid Mudgal book, a bit tweaked by me.
 
Ranch Hand
Posts: 262
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is it because of '? extends ' instead of '? super' expression, the compiler wont let me add anything to the list.



Yes.
But it's important to understand why. I suggest you go through the following post also

http://www.coderanch.com/t/627111/java-programmer-SCJP/certification/difference-List-super-Dog-animals#2869356

and try to understand the question and the responses. I think that might give you more clarity.

 
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this post
 
Do you want ants? Because that's how you get ants. And a tiny ads:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!