ArrayList arr=new ArrayList();
ArrayList arr=new ArrayList();
List arr=new ArrayList<>();
What is the difference in these declarations if any
ArrayList arr=new ArrayList();
ArrayList arr=new ArrayList();
List arr=new ArrayList<>();
What is the difference in these declarations if any
Two important concepts are involved in these declarations
1.Run time polymorphism
2. Generics in java
Please have a look into these concepts.
Now when a parent reference is pointing to child object like in case
List arr = new Arraylist<>()
Then on method calling through parent reference you have certain limitations.
Like you can call only overridden methods or methods of parent class.
Thanks
Can u please explain in simple terms please I haven’t reached OOPS yet
the difference between these two is of importance when you come to run time polymorphism. until then you can use any of them for your programs.
Thanks.
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.