What is the difference of
LinkedList<String> l1 = new LinkedList<String>();
List<String> l2 = new LinkedList<String>();
Why does l2
type don't have method addFirst
while
l1
type have method addFirst
? even though they are both
hold a LinkedList
object?
Contrary to what I read from Gosling's "The Java Programming language"
which states that the object will be what you made it to be,
in this case I made it a LinkedList
with new LinkedList()
even though
it is of type List
How should I properly declare then?
Collection<String> c = new LinkedList<String>();
List<String> c = new LinkedList<String>();
LinkedList<String> c = new LinkedList<String>();