Товарищи, подскажите, где ошибка?
package com.javarush.task.task08.task0820;
import java.util.HashSet;
import java.util.Set;
/*
Множество всех животных
*/
public class Solution {
public static void main(String[] args) {
Set<Cat> cats = createCats();
Set<Dog> dogs = createDogs();
Set<Object> pets = join(cats, dogs);
printPets(pets);
removeCats(pets, cats);
printPets(pets);
}
public static Set<Cat> createCats() {
Set<Cat> result = new HashSet<Cat>();
Cat cat1 = new Cat();
Cat cat2 = new Cat();
Cat cat3 = new Cat();
Cat cat4 = new Cat();
result.add(cat1);
result.add(cat2);
result.add(cat3);
result.add(cat4);
return result;
}
public static Set<Dog> createDogs() {
Set<Dog> dogs = new HashSet<Dog>();
Dog dog1 = new Dog();
Dog dog2 = new Dog();
Dog dog3 = new Dog();
dogs.add(dog1);
dogs.add(dog2);
dogs.add(dog3);
return dogs;
}
public static Set<Object> join(Set<Cat> cats, Set<Dog> dogs) {
Set<Object> pets = new HashSet<>();
pets.addAll(cats);
pets.addAll(dogs);
return pets;
}
public static void removeCats(Set<Object> pets, Set<Cat> cats) {
for (Object Cat : pets) pets.remove(Cat);
}
public static void printPets(Set<Object> pets) {
for (Object wer : pets) System.out.println(pets);
}
public static class Cat {
}
public static class Dog {
}
}