I came across the following code and was wondering whether this is good practice:
LinkedList<String> ll = new LinkedList();
I would have written
List<String> l = new LinkedList<String> ();
So there are two questions here:
- I always thought its good practice to use the type
List
and notArrayList
/LinkedList
. - What exactly happens if you omit the diamond on the RHS of the assignment operator?