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());

```
The use of these obsolete -though not deprecated- classes is often a business decision. There's not much you can do about it, except, if possible, use a different API.

I wouldn't use `Vector`. If you don't need the synchronisation in your own code, use the Collections Framework. If you do need the synchronisation, use the synchronisation, use the classes from `java.util.concurrent`.

Either way, use `Collections.enumeration` to convert them to an enumeration.