哪里错了?
package zh.codegym.task.task08.task0824;
/*
构建家庭
*/
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) {
//在此编写你的代码
ArrayList<Human> humans=new ArrayList<>();
humans.add(new Human("zufu1",true,78));
humans.add(new Human("zufu2",true,78));
humans.add(new Human("zumu1",false,78));
humans.add(new Human("zumu2",false,78));
humans.add(new Human("fuqin",true,28));
humans.add(new Human("muqin",false,28));
humans.add(new Human("haizi1",false,8));
humans.add(new Human("haizi2",false,8));
humans.add(new Human("haizi3",false,8));
System.out.println(humans);
}
public static class Human {
//在此编写你的代码
String name;
boolean sex;
int age;
ArrayList<Human> children =new ArrayList<>();
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,ArrayList<Human> list){
this(name, sex, age);
this.children =list;
}
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;
}
}
}