• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Generics

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry all!!.
I was using AnimalDoctorGeneric1 instead of AnimalDoctorGeneric2 .It was working fine.
 
Ranch Hand
Posts: 99
Mac Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Attractive, successful people love this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic