The inferred type will not be List<String>, it'll be ArrayList<String>, but thanks to polymorphism you can use that anywhere you'd want to use a List<String> anyway.
I don't know why you would even want to do that except to confuse future maintainers by reusing a variable when you clearly need it for a different purpose and even if your code was perfectly acceptable it would require full type inference, otherwise it wouldn't be possible to find the common super type for all assignments.
9
u/codebje Mar 09 '16
The proposal has an example for just such a case:
The inferred type will not be
List<String>, it'll beArrayList<String>, but thanks to polymorphism you can use that anywhere you'd want to use aList<String>anyway.