Why did Sir use <>() while creating array list in if loop

Jus t wanted to ask Why did Sir use <>() while creating array list in if loop but he did not use <> when creating a new ArrayList for recResult. Does <> not matter or I have missed something.

hey @code_breaker-1001 <>definitely matters in the code however you can skip <>this in RHS.for eg.
ArrayList ar = new ArrayList<>(); is similar to ArrayList ar = new ArrayList();

But then when do we use <> for declaring arraylist…

hey @code_breaker-1001 It depends on you putting <> on RHS is not necessary so if you want add It otherwise dont

ohk, then just what is the purpose of this <> in ArrayList then?

hey @code_breaker-1001 <> specifies that the arrayList is a generic list means it can be of any type from int, boolean, long, char to even classes.

ohk Thank you…

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.