Добрый день,помогите что за ошибка StackOverFlowError,пытаюсь запустить код,все время она...
package com.javarush.task.task07.task0724;
/*
Семейная перепись
*/
import java.util.ArrayList;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
Human jonny = new Human("Jonny", true, 42);
Human jack = new Human("Jack", true, 52);
Human landy = new Human("Landy", false, 82);
Human kelly = new Human("Kelly", false, 61);
Human rita = new Human("Rita", false, 11, jack, landy);
Human boris = new Human("Boris", true, 7, jonny, kelly);
Human arthur = new Human("Arthur", true, 21, jonny, kelly);
Human rainbow = new Human("Rainbow", true, 1, jack, landy);
Human ree = new Human("Ree", false, 2, jack, landy);
System.out.println(jonny.toString());
System.out.println(jack.toString());
System.out.println(landy.toString());
System.out.println(kelly.toString());
System.out.println(rita.toString());
System.out.println(boris.toString());
System.out.println(arthur.toString());
System.out.println(rainbow.toString());
System.out.println(ree.toString());
}
public static class Human {
private String name;
private boolean sex;
private int age;
Human father = new Human();
Human mother = new Human();
public Human() {
}
public Human(String name, boolean sex, int age) {
this.name = name;
this.sex = sex;
this.age = age;
}
public Human(String name, boolean sex, int age, Human father, Human mother) {
this.name = name;
this.sex = sex;
this.age = age;
this.father = father;
this.mother = mother;
}
public String toString() {
String text = "";
text += "Имя: " + this.name;
text += ", пол: " + (this.sex ? "мужской" : "женский");
text += ", возраст: " + this.age;
if (this.father != null) {
text += ", отец: " + this.father.name;
}
if (this.mother != null) {
text += ", мать: " + this.mother.name;
}
return text;
}
}
}