Is this an error?Only Map has values() method. This method returns a Set of values stored in the Map.
A Set contains no duplicate elements. Although the keys of a Map cannot contain duplicates, the values can. Hence, Map.values() can't return a Set, it returns a Collection.