[Solved] java.lang.StackOverflowError when trying to add the same instance of list multiple times

[ad_1]

All your Parent instances have the same list of children, since you construct a single ArrayList and use it as the children of all three Person. So you have a recursive data structure. Create a different list for each person.

[ad_2]

solved java.lang.StackOverflowError when trying to add the same instance of list multiple times