The object created is exactly the same.
The difference is in variable type.
Variable
a can only hold a reference to
ArrayList (or anything that extends
ArrayList -- for example
javax.management.AttributeList).
Variable
l can hold a reference to anything that implements
List interface so you could assign a reference to
LinkedList to
l.
Generally
you should program to interfaces. If your program does not depend on a particular implementation of
List (
ArrayList in this case), you should define lists as
List.
If you ever need to change type of a list, you would need to make only one change in a code (instead of 42381 changes
)