I was a bit confused, when we use
List<String> lst = new LinkedList<>();
when we use
LinkedList<String> lklst = new LinkedList<>();
At the beginning, I thought they are the same, but today, I realized they are not the same. For example, if I call lst.getFirst()
It will tell me there is a error. However, if i do lklst.getFirst()
, it works fine. My question is when do we use lklst then? why they are different? Also, does it apply same rule for Map. THanks!