Doubt in arguments for method

  1. why we have passed Scanner inside the method as an argument ?

  2. how the root node i.e “60” got inside into an arraylist as arraylist is created afterwards the data is put
    for example:
    this.data=data;
    this.children=new arraylist();
    how data got into an arraylist;

@dheerajmishra992,

We would pass a Scanner object as a parameter into a method when we want that method to be more reusable.

It happens at the end of recursion. this.data stores the value in the data variable.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.