Is there any difference between enum
datatype and Enumeration
Interface. I have become confused between the two.
I got my answer that they aren't related but that brings me to another question.
We cannot instantiate interface . So what is the significance of this line
Enumeration days = dayNames.elements();
Heres the complete code containing that line
import java.util.Vector;
import java.util.Enumeration;
public class EnumerationTester {
public static void main(String args[]) {
Enumeration days;
Vector dayNames = new Vector();
dayNames.add("Sunday");
dayNames.add("Monday");
dayNames.add("Tuesday");
dayNames.add("Wednesday");
dayNames.add("Thursday");
dayNames.add("Friday");
dayNames.add("Saturday");
days = dayNames.elements();
while (days.hasMoreElements()){
System.out.println(days.nextElement());
}
}
}