If I run the code, the removal worked, and only 2 elements are printed to standard output,
Does anyone have a clue, why the last requirement isn't fulfilled?
package com.codegym.task.task08.task0819;
import java.util.HashSet;
import java.util.Set;
/*
Set of cats
*/
public class Solution {
public static void main(String[] args) {
Set<Cat> cats = createCats();
//write your code here. step 3
cats.remove(Cat.cat3);
printCats(cats);
}
public static Set<Cat> createCats() {
//write your code here. step 2
Set<Cat> catset = new HashSet<>();
catset.add(Cat.cat1);
catset.add(Cat.cat2);
catset.add(Cat.cat3);
return catset;
}
public static void printCats(Set<Cat> cats) {
// step 4
Object[] a = cats.toArray();
for(int i = 0 ; i < a.length; i ++ ){
System.out.println(a[i]);
}
}
public static class Cat {
public static Cat cat1 = new Cat();
public static Cat cat2 = new Cat();
public static Cat cat3 = new Cat();
public Cat(){
}
}
// step 1
}