Java- array as return type of the method and not arraylist


#1

In Java, the return type of method is given as array and not arraylist. How do we dynamically decide the value of the array. I think there is a bug in here. or we have to calculate the no of nodes in the tree first and then declare the array of that size and return it. Even the solution has array list as the return type