Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics

 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've written this code. Could anyone tell me what should I write in place of /* Commented part */ so that it compiles and invoke the getName() method on each of the object stored in aList.

Thanks
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Notice here that ia is the iterator, it is not an element from the list.

If you change the print statement to



you should get the results you want.

Note also that you have a semicolon where you don't need it in the while loop.
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Keith. Its working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic