here to get updates on new
24. Three Cursors of Java - Iterator ?
1. We can apply iterator concept for any Collection object
hence it is universal cursor.
2. By using iterator we can perform both read and remove
operations.We can create iterator object by using iterator()
method of Collection Interface
public iterator iterator();
Where C is any Collection Object.
Methods In Iterator
Iterator Interface defines the following three methods
1. public Boolean hasNext()
2. public Object next()
3. public void remove()
1. By using Enumeration and Iterator
we can move only towards forward direction and we can’t
move to the backward direction, and hence these are single
2. By using Iterator we can perform only read and remove
operatiions and we can’t perform replacement of new
overcome above limitations of Iterator we should go for