Can someone explain what is different between the two instances of the class ArrayList?
List<Integer> intList = new ArrayList();
List<Integer> intList = new ArrayList<Integer>();
I knew that the compiler erases a type variable, i.e. Integerwhen compiles it into bytecode, and the above example works exactly the same. I wonder if there is any use at all for passing a variable of type ( Integer) on the right side, since it is already declared on the left? As far as I can find on the Internet, they all use the latter, but I see no reason why I should announce it twice on both sides.
source
share