When I initialize List, I am able to do this:
List<Object[]> foo = new ArrayList<>();
foo.add(new Object[]{816, "foo", 2.6});
But when I want to simplify it using Arrays.asList
:
List<Object[]> bar = Arrays.asList(new Object[]{"bar", 286});
It cannot compile with error:
incompatible types: inference variable T has incompatible bounds
equality constraints: java.lang.Object[]
lower bounds: java.lang.Object
Why it cannot do the type inference right and how to fix this?