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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Iterator of an ArrayList" Watch "Iterator of an ArrayList" New topic
Author

Iterator of an ArrayList

Joey Sanchez
Ranch Hand

Joined: Jun 23, 2011
Posts: 86

Where does the error come from?

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19073
    
  40

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.

Henry


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
http://mysqlearner.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterator of an ArrayList