Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Iterator for ArrayList

807588May 24 2009 — edited May 24 2009
I want to use an iterator to step through an ArrayList (apparently its better than using get(i)), but I keep running into errors:
//When declared as
ArrayList<Thing>[] things = new ArrayList[3];
//then
Iterator myThing = things[0].iterator();
//error: 'cannot find symbol. symbol: Iterator. class: the class where this code appears

//Or like this:
List<Thing>[] things = new ArrayList[3];
//error:type java.awt.list does not take parameters

//Or:
List[] things = new ArrayList[3]
//error: incompatible types. found: java.util.ArrayList[]. required: java.util.List[]
Hope someone can explain to me how to correctly declare my 'things' and generate an iterator to step through them. I've seen examples on this forum which look identical to what I've typed, but I must be doing something wrong...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2009
Added on May 24 2009
4 comments
451 views