In Java 10, this is giving me a warning -
ArrayList a = new ArrayList<>();
a.add(23);
a.add("str");
"ArrayList is a raw type. References to generic type ArrayList should be parameterized"
And the reason is Generic behind, but for this code
var b = new ArrayList<>();//Object type
b.add(3);
b.add("string");
Why was any warning not given by compiler?
Note:- I know var
is limited to method scope. Just wanted to know design concept resected to generics for var
Edit1:- Don't mark as duplicate as I just wanted to know about internal design and why java not added generic stuff for var?