Relationship between class and iterator interface

Will a class become an iterator object itself if it implements an iterator interface.

For example,

public class StringGridIterator implements Iterator<String>{

    //some methods here...


or Do I need to specifically create a variable reference to an iterator object that will iterate through a certain String objects?

like this...

Iterator<String> it = object.iterator();

I don't know if this is clear enough for you to understand since I am still struggling with understanding Java concept like class and object myself.. Just leave a comment if you don't understand what I am trying to say.


A class will not become an Iterator object by implementation. You may be thinking of extending a class. (See: What's the difference between the implements & extends keywords in Java).

From your examples, it looks like you are attempting to do 2 different things: class inheritance vs. an iterator object. The .iterator() method returns an Iterator containing the elements of your object.

Need Your Help

UITableViewCell staying empty

ios objective-c uitableview

I am trying to fill a UITableView with the objects of an NSMutableArray which is filled from a table in Parse. The array is definitely being filled (I checked its contents with an NSLog), but the t...

Android Back Timer Button

android text timer

i want to make a simple timer of 60 sec. When i tap the button my timer begins. And when the time=0 then set text to some string. Help me how can i do it for android inside Activity:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.