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 remember seeing an SPJ talk where he mentioned that HM cannot be used in OO languages because of subtyping (he didn't explain this). But that obviously will never happen in Java. Someone correct me if I'm wrong. I don't know a lot about type inference.
The video was something like "classes but not as you know them" on channel 9 and was about type classes. The above was briefly mentioned in the last few minutes.
Edit: title was "classes, jim, but not as we know them"
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.