I am new to Java. I want to know the difference between:
List< String > list = new ArrayList<>();
and
ArrayLis
The first one is only valid since Java 7, and is the equivalent of
List list = new ArrayList();
It's just less verbose.
Same for the third one, which is equivalent to
ArrayList list = new ArrayList();
and thus strictly equivalent to the second one.
You should prefer the first one, for the reasons mentioned in the answers to the following question: List versus ArrayList as reference type?