Question: 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?](https://stackoverflow.com/q/2986296/3647002)

So I don't think this qualifies as a duplicate.

Answer: 
Neither. You don't need either of these. `Collections.enumeration()` takes a `Collection` argument, and `Set` is a `Collection`, and `Map.keySet()` returns a `Set`.

You just need:

```
return Collections.enumeration(map.keySet());

```
well depending on on your use case, use ArrayList if you don't care about thread safety so you don't get the additional overhead of synchronized methods of Vector,
otherwise use Vector .