So I started learning Java about a month ago. And there is this one thing that I can't quite put my finger on.
What is difference between
List<String> list1 = new ArrayList<>();
and
ArrayList<String> list2 = new ArrayList<>();
I get that in list1 declaration is done by using name of Array class and initialization by using name of ArrayList class, and in list2 declaration and intialization both are done by using name of ArrayList class. But what is the difference if there are any.
And even when I make object for inherited class and do the same thing, declaration using name of one class and initializing using name of other. Is there any difference apart form the fact that the code looks different??
Ps : Kinda new to all the terminology and learned most stuff from books, oracle website and stuff but not completely from one source so if i made any mistake please correct me :)