Help with tree recursion

后端 未结 3 2100
醉酒成梦
醉酒成梦 2021-01-15 16:43

I have a Person class, and I want to create a tree. Here is the contsructor for the Person class.

public Person(String name, int age, char gender, Person c1         


        
3条回答
  •  灰色年华
    2021-01-15 17:18

    private int count() {
        return 1 + ((this.child1 != null) ? (this.child1.count()) : (0)) + ((this.child2 != null) ? (this.child2.count()) : (0));
    }
    

提交回复
热议问题