Cursors are used to travers through the elements one by one. enumeration is one type of cursor in Java. Its mainly used in case of legacy classes like Vector.
Example:
import java.util.Enumeration;
import java.util.Vector;
public class CursorTest {
public void enumerationTest(){
Vector<Integer> v=new Vector<Integer>();
for(int i=0;i<10;i++){
v.addElement(i);
}
System.out.println(v);
Enumeration<Integer> e=v.elements();
while(e.hasMoreElements()){
Integer I=(Integer)e.nextElement();
if(I%2==0){
System.out.println(I);
}
}
System.out.println(v);
}
}
Methods used with enumeration are-
hasMoreElements()
nextElement()