| Author |
Help in generics
|
jose chiramal
Ranch Hand
Joined: Feb 12, 2010
Posts: 266
|
|
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
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2699
|
|
|
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.
|
Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
|
 |
Prithvi Sehgal
Ranch Hand
Joined: Oct 13, 2009
Posts: 771
|
|
Hello jose,
Check JavaGenericsFaq
Hope this helps,
|
Prithvi/Beenish,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
|
 |
 |
|
|
subject: Help in generics
|
|
|