This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections mock question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Collections mock question" Watch "Collections mock question" New topic
Author

Collections mock question

adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186


why would line 10 generate compatible error?!


boolean b = true;<br />System.out.println ("I believe in Java.<br />Java will make my dream come " + b);
sathi jogi
Greenhorn

Joined: Aug 31, 2007
Posts: 14
hi,

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
System.out.println(obj);
}
adam Lui
Ranch Hand

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

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

possible?
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 ]

SCJP5 - SCWCD5 - SCBCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collections mock question
 
Similar Threads
Static Blocks
sum of non numeric elements in an ArrayList
Linked List - inserting value to correct position
TypeCasting in Generics
enthuware error?