Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343705 - Misleading error
Summary: Misleading error
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-24 11:38 EDT by Jonathan Camilleri CLA
Modified: 2011-04-26 03:54 EDT (History)
2 users (show)

See Also:


Attachments
Source code (dummy) (7.13 KB, application/octet-stream)
2011-04-24 11:38 EDT, Jonathan Camilleri CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Camilleri CLA 2011-04-24 11:38:14 EDT
Build Identifier: M20110210-1200

I'm trying to code as follows, however, I'm getting an error message, any idea why?
private static ArrayList<Player> getWinner(ArrayList<Player> _players) {
...
for (int i = 0; i < _players.size(); i++) {
for (Card _card: _players.get(i)) {

}
}
return _winners;
...
}

Error: 
Can only iterate over an array or an instance of java.lang.Iterable

According to the Java API for 1.6, ArrayList implements Iterable<E> - http://download.oracle.com/javase/6/docs/api.



Reproducible: Always
Comment 1 Jonathan Camilleri CLA 2011-04-24 11:38:50 EDT
Created attachment 193969 [details]
Source code (dummy)
Comment 2 Chris West (Faux) CLA 2011-04-24 11:48:16 EDT
Sorry, where in that example are you attempting to iterate over an ArrayList using the foreach syntax?
Comment 3 Jonathan Camilleri CLA 2011-04-24 11:49:37 EDT
(In reply to comment #2)
> Sorry, where in that example are you attempting to iterate over an ArrayList
> using the foreach syntax?
Yes, is my coding incorrect?
Comment 4 Jonathan Camilleri CLA 2011-04-24 11:50:18 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > Sorry, where in that example are you attempting to iterate over an ArrayList
> > using the foreach syntax?
> Yes, is my coding incorrect?

I found a sample at http://leepoint.net/notes-java/flow/loops/foreach.html.
Comment 5 Dani Megert CLA 2011-04-26 03:46:24 EDT
Bugzilla is not here to answer coding questions. Use a Java newsgroup for that.
Comment 6 Jonathan Camilleri CLA 2011-04-26 03:54:14 EDT
(In reply to comment #5)
> Bugzilla is not here to answer coding questions. Use a Java newsgroup for that.

Noted