Skip to content
Java List and ArrayList
Profile icon
ShadeVI

Hi guys,
is there any difference between these two ways?

List wordlist = new ArrayList <> ();

and

ArrayList wordlist = new ArrayList ();

You are viewing a single comment. View All
Answered by hellooneplus [earned 5 cycles]
View Answer
Profile icon
Coder100

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 for List.
https://java2blog.com/java-list-vs-arraylist/