• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help in generics  RSS feed

 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Could someone please help me understand the below concept :

"An ArrayList<Animal> can accept references of type Dog, Cat, or any other subtype of Animal (subclass, or if Animal is an interface, implementation)."


Additionally could someone please point me to understand any good link for understanding the concepts used in Generics.
 
Devaka Cooray
Marshal
Posts: 5516
687
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In simple terms, if there is a reference like "ArrayList<Animal> anim", you can add a dog, cat, cow, or any other animal into that object, using the add(-) method. You may have a look at the Sun Generics tutorial.
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello jose,

Check JavaGenericsFaq

Hope this helps,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!