Метод выдает ощибку
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human grendfather = new Human("Вася",true,75);
Human grendfather2 = new Human("Вітя",true,69);
Human grendmather = new Human("Сарія",false,56);
Human grendmather2 = new Human("Софія",false,45);
Human father = new Human("Ігор",true,35);
Human mather = new Human("Горпина",false,23);
Human child1 = new Human("Саша",true,5);
Human child2 = new Human("Іріна",false,7);
Human child3 = new Human("Вадим",true,11);
ArrayList<Human> children = new ArrayList<>();
children.add(child1);
children.add(child2);
children.add(child3);
System.out.println(father.toString());
}
public static class Human {
//напишите тут ваш код
ArrayList<Human> children;
String name;
boolean sex;
int age;
public Human (String n, boolean s, int a){
name=n;
sex=s;
age=a;
}
public String toString() {
String text = "";
text += "Имя: " + this.name;
text += ", пол: " + (this.sex ? "мужской" : "женский");
text += ", возраст: " + this.age;
int childCount = this.children.size();
if (childCount > 0) {
text += ", дети: " + this.children.get(0).name;
for (int i = 1; i < childCount; i++) {
Human child = this.children.get(i);
text += ", " + child.name;
}
}
return text;
}
}
}