The following code works fine.
List<Integer> arr = new ArrayList<Integer>();
System.out.println(arr.getClass().getSimpleName()); // output: ArrayList
arr.add(0);
arr.add(1);
arr = arr.subList(0,1);
But if you change the first line to
var arr = new ArrayList<Integer>();
an error will occur:
java: incompatible types: java.util.List<java.lang.Integer> cannot be converted to java.util.ArrayList<java.lang.Integer>
However, even if arr is defined in the second way, its type is still ArrayList, so what is the difference?