I have this code below:
public static <E> Set<E> union(Set<E> set1, Set<E> set2) {
Set<E> resultSet = new HashSet<>(set1);
resultSet.addAll(set2);
return resultSet;
}
I want to overload one method like below, and get bound mismatch:
public static <E> Set<E> union(EnumSet<E extends Enum<E>> set1, EnumSet<E extends Enum<E>> set2){
Set<E> resultSet = set1.clone();
resultSet.addAll(set2);
return resultSet;
}
And I change to below, and it doesn't work.
Why? And how can I do?