aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Iterator of an ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Iterator of an ArrayList" Watch "Iterator of an ArrayList" New topic

Iterator of an ArrayList

Joey Sanchez
Ranch Hand

Joined: Jun 23, 2011
Posts: 86

Where does the error come from?

Henry Wong

Joined: Sep 28, 2004
Posts: 19827

Joey Sanchez wrote:Where does the error come from?

You are trying to instantiate an object of the myL.interator class. Notice the "new" operator.... and it is complaining that it can't find such a class.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Zeeshan Sheikh
Ranch Hand

Joined: Nov 20, 2011
Posts: 144

Iterator i = new myL.iterator(); //Wrong Statement

Just take new operator out

Iterator i = myL.iterator(); //Right Statement

You are accessing iterator method of ArrayList so there is no need for 'new' operator. Hope this helps.

MySQL Blog
It is sorta covered in the JavaRanch Style Guide.
subject: Iterator of an ArrayList