What is an iterator?

Showing Answers 1 - 11 of 11 Answers

iterator is interface that is used for step through element of collection.it is interface in java.util package.it is part of collection framework.

syntnax:

Iterator i=c.iterator();

while(i.hasNext())

{

Object o=i.next();

}

  Was this answer useful?  Yes

Swaminathan. R

  • Jul 4th, 2006
 

Iterators are coming under STL (Standard Template Library)Iterators are act like pointers.Types of Iterators:1. Reverse Iterators: a) Random access ? store & retrieve values, random access (RandIter) b) Bidirectional ? store & retrieve values, forward & backward moving (BiIter)2. Forward Iterator ? store & retrieve values, forward moving only (ForIter)3. Input Iterator ? retrieve values, forward moving only (InIter)4. Output Iterator ? store values, forward moving only (OutIter)

Iterator is a class that is used to traverse through the objects maintained by a container class.
these are five types are:-
1.Input iterator
2.output iterator
3.forward iterator
4.bidirectional iterator
5.random iterator
An iterator is an entity that gives access to the contents of a container objects without violating encapsulation constraints.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions