The advantage of declaring variables and parameters as List instead of the specific implementation like ArrayList or LinkedList is that generic method calls can accept any List; this becomes most useful when you're writing generic library code, or when in your code you use some of the exotic implementations (like those in Guava or Apache Commons) for some useful purpose, as is often done for immutability, data locality, or code simplification.
Java actually provides a marker interface to distinguish between implementations of lists that support fast random access [1] and those that don't, and library code is encouraged to use this to decide an optimal codepath.
Java actually provides a marker interface to distinguish between implementations of lists that support fast random access [1] and those that don't, and library code is encouraged to use this to decide an optimal codepath.
[1] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAc...