This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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

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: 18874

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
GeeCON Prague 2014
subject: Iterator of an ArrayList