If I call a (generic) varargs method with objects of different classes, I get an interesting warning:
List<?> result = Arrays.asList("1", 1);
A generic array of Object&Serializable&Comparable is created for a varargs parameter
I can get rid of the warning by casting to a common interface or class,
List<Serializable> result = asList((Serializable) "1", (Serializable) 1);
but what does Object&Serializable&Comparable<?>
mean? Can it be used in generic type annotations on method signatures as well (like extends
or super
)?