Why am I getting an AssertionError when assigning Arrays.asList() to var directly?
I'm trying to understand local variable type inference in Java 10. The code below works perfectly during compilation and runtime: List list1 = Arrays.asList(1L, 2.0F, "3"); var list2 = list1; However, this line throws a compilation error: var list3 = Arrays.asList(1L, 2.0F, "3"); Error:java: java.lang.AssertionError: Unexpected intersection type: java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>> I don't really understand why the 2nd case is wrong but not the 1st case. Because I expect the compiler would infer the