Enumeration interface has method hashMoreElements is used with refrence variable (Enumv), how can they be used
since they are not implemented ?
I meant it is an interface method so how can it be called – Enumv.hasMoreElements() it does not have a implementation .
Vector v = new Vector();
//v contains list of elements - Suppose
Enumeration Enumv = v.elements();
while(Enumv.hasMoreElements()) {
System.out.println(Enumv.nextElement());
}
How is this possible?
For your code,
This is what
Vectoris returning to you.As you can see, Vector returns an implemented
Enumerationclass (which annonymous to the developer).It is implemented (as shown above).