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


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.

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