I'm confused about the purpose of the array list being used in the class. Previously, we have initialized objects without using an array list as a field. So I'm wondering what's the benefit of doing it this way. Furthermore, I've seen that some people have created 3 array lists to account for each child which adds to my confusion. I just don't get it.
Help me understand
You must be signed in to leave a comment
11 November 2019, 16:16
The ArrayList construct is used because the amount of children is going to be an unknown number that can change. An Array would not work as well as doing child1, child2, child3 etc.
18 November 2019, 18:36
Thanks for taking the time to answer. Much appreciated.