Здравствуйте. Подскажете почему в конце метода пишется return null? Написал, потому что IDEA предложила. Сам не понимаю для чего оно там.
public String toString() {
if (mother == null && father == null)
return "Cat name is " + name + ", no mother, no father ";
else if (mother != null && father == null)
return "Cat name is " + name + ", mother is " + mother.name + ", no father";
else if (mother == null && father != null)
return "Cat name is " + name + ", no mother, father is " + father.name;
else if (mother != null && father != null)
return "Cat name is " + name + ", mother is " + mother.name + ", father is " + father.name;
return null;
}