I have this code below displaying the values in a vector using the methods (method1 and method2)
both giving the same result
I would like to know what it the advantage using enumeration interface
public class En1
{
public void method1()
{
Vector a = new Vector();
a.add("a");
a.add("b");
for(int i = 0;i < a.size();i++)
{
System.out.println(a.elementAt(i));
}
public void method2()
{
Vector a = new Vector();
a.add("a");
a.add("b");
for (Enumeration e = a.elements(); e.hasMoreElements()
{
String myString = (String) e.nextElement();
System.out.println(myString);
}
}
}