The JAVA DOC of Vector class shows that implemented interfaces in this class are Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess
The Vector's elements()
method signature is: public Enumeration<E> elements()
calling
Which returns an instance of implemented Enumeration
as is evident from following source code:
public Enumeration<E> elements() {
return new Enumeration<E>() { // return implemented enumeration
int count = 0;
public boolean hasMoreElements() {
return count < elementCount;
}
public E nextElement() { // implementing nextElement
synchronized (Vector.this) {
if (count < elementCount) {
return elementData(count++);
// accessing vector elements data which
//traverses an array of object
}
}
throw new NoSuchElementException("Vector Enumeration");
}
};
}