Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Iterator of an ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 70

Where does the error come from?

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16687
    
  19

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

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.

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Iterator of an ArrayList
 
Similar Threads
Generic question
Can someone explain the error @ Line-03
inheritance (need help)
import and extends (need help!!)
getting access to grandfather's constructor