aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generics" Watch "Generics" New topic
Author

Generics

kathir vel
Ranch Hand

Joined: Jul 03, 2007
Posts: 92
Hi All,
In this following program I couldn't see the execution of Line 1 and Line 2. Anyone please clarify me?Thanks.





code indenting repaired by using the button, Bu
[ July 18, 2007: Message edited by: Burkhard Hassel ]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Kathir,

What couldn't you see on line #1 and #2. You are passing a list to the method,
adding Dog, Cat and Bird objects to it accordingly. Inside the method, you are
adding a Dog object to every passed list and after printing its size, you
are traversing the list.
What do you see wrong there?



Thanks,


cmbhatt
kathir vel
Ranch Hand

Joined: Jul 03, 2007
Posts: 92
Sorry all!!.
I was using AnimalDoctorGeneric1 instead of AnimalDoctorGeneric2 .It was working fine.
Abdullah Mamun
Ranch Hand

Joined: Mar 19, 2007
Posts: 99

Hi Kathir,
The source gives compiler error at the following lines

The reason is, there is a down casting from List to ArrayList. So you have to cast explicitly.

[ July 17, 2007: Message edited by: Al Mamun ]

MooN
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics