Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterator of an ArrayList  RSS feed

 
Joey Sanchez
Ranch Hand
Posts: 92
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where does the error come from?

 
Henry Wong
author
Sheriff
Posts: 22843
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Zeeshan Sheikh
Ranch Hand
Posts: 144
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!