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

```
I think that if you want to just get Enumeration there is no difference.

Vector constoructor is as below.

```
public Vector(Collection<? extends E> c) {
    elementData = c.toArray();
    elementCount = elementData.length;
    // c.toArray might (incorrectly) not return Object[] (see 6260652)
    if (elementData.getClass() != Object[].class)
        elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
}

```

ArrayList constructor is as below.

```
 public ArrayList(Collection<? extends E> c) {
    elementData = c.toArray();
    if ((size = elementData.length) != 0) {
        // c.toArray might (incorrectly) not return Object[] (see 6260652)
        if (elementData.getClass() != Object[].class)
            elementData = Arrays.copyOf(elementData, size, Object[].class);
    } else {
        // replace with empty array.
        this.elementData = EMPTY_ELEMENTDATA;
    }
}

```