aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Help in generics Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Help in generics" Watch "Help in generics" New topic
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
    
    3

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Help in generics
 
Similar Threads
Generics
Generics + Polymorphism
Generics doubt ?
generics
wildcards in generics