This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections mock question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections mock question" Watch "Collections mock question" New topic

Collections mock question

adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186

why would line 10 generate compatible error?!
sathi jogi

Joined: Aug 31, 2007
Posts: 14

here you are trying to retrieve the list objects from the arraylist, that is not right, you are retrieving objects from the list,

so modify the line 10 as given below,

for (Object obj:getList()) //line 10
adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186
so we use ....
for (Object obj: getlist())

wat about ...
for (ArrayList obj: getList())

al nik
Ranch Hand

Joined: Oct 18, 2007
Posts: 60
it's possible if for example your getList() method returns a "List of ArrayList"

but this is not your case..
[ October 21, 2007: Message edited by: al nik ]

I agree. Here's the link:
subject: Collections mock question
It's not a secret anymore!