See the two different implementations that return Enumeration<?>
Vector<String> v = new Vector<>(map.keySet());
return v.elements();
List<String> v = new ArrayList<>(map.keySet());
return Collections.enumeration(v);
Please note that the return type here Enumeration<?>
, cannot be changed.
Is there any advantage of using one over the other?
As Enumeration classes are synchronized, should I better stick with Vector
?
My intention was not to compare Vector vs ArrayList, but to find the better implementation from the above two specific code usages. The answers here are also different from What are the differences between ArrayList and Vector?
So I don't think this qualifies as a duplicate.