Hi guys, is there any difference between these two ways?
List wordlist = new ArrayList <> ();
and
ArrayList wordlist = new ArrayList ();
List is abstract, so you can change it's 'type'. ArrayList is not, but it will allow you more speed if you know all your types are going to be the same.
List
ArrayList
I have always used ArrayList, and have never found any need for List. https://java2blog.com/java-list-vs-arraylist/
Java List and ArrayList
Hi guys,
is there any difference between these two ways?
List wordlist = new ArrayList <> ();
and
ArrayList wordlist = new ArrayList ();
Difference
List
is abstract, so you can change it's 'type'.ArrayList
is not, but it will allow you more speed if you know all your types are going to be the same.Which one to use?
I have always used
ArrayList
, and have never found any need forList
.https://java2blog.com/java-list-vs-arraylist/