help me analyze the code I can't find the bug
package com.codegym.task.task08.task0824;
/*
Make a family
*/
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) {
//Creating Objects
ArrayList<Human> grandCh = new ArrayList<>();
ArrayList<Human> kids = new ArrayList<>();
Human child = new Human("ucee", true, 22, new ArrayList());
Human child2 = new Human("mikak", false, 23, new ArrayList());
Human child3 = new Human("ben", true, 24, new ArrayList());
grandCh.add(child);
grandCh.add(child2);
grandCh.add(child3);
Human f = new Human("father", true, 90, grandCh);
Human m = new Human("mother", false, 90, grandCh);
kids.add(f);
kids.add(m);
Human gf = new Human("papa", true, 90, kids);
Human gf2 = new Human("papa2", true, 90, kids);
Human gm = new Human("Mama", false, 90, kids);
Human gm2 = new Human("Mama2", false, 90, kids);
System.out.println(gf.toString());
System.out.println(gf2.toString());
System.out.println(gm.toString());
System.out.println(gm2.toString());
System.out.println(f.toString());
System.out.println(m.toString());
System.out.println(child.toString());
System.out.println(child2.toString());
System.out.println(child3.toString());
}
public static class Human {
//write your code here
String name;
//String name = new String("mikasa");
boolean sex;
int age;
ArrayList<Human> children = new ArrayList<>();
public Human(String name, boolean sex, int age, ArrayList<Human> children){
this.name = name;
this.sex = sex;
this.age = age;
this.children = children;
}
public String toString() {
String text = "";
text += "Name: " + this.name;
text += ", sex: " + (this.sex ? "male" : "female");
text += ", age: " + this.age;
int childCount = this.children.size();
if (childCount > 0) {
text += ", children: " + this.children.get(0).name;
for (int i = 1; i < childCount; i++) {
Human child = this.children.get(i);
text += ", " + child.name;
}
}
return text;
}
}
}