I get "Type mismatch: cannot convert from List<CherryCoke> to List<Coke<?>>"
It looks like a 'list of cherry cokes' is not a 'list of cokes'. This is counterintuitive.
How can I create that 'xs' anyway, if it has to be a List<Coke<?>> and I have to have a subclass of Coke<Cherry> ?
class Taste { }
class Cherry extends Taste { }
abstract class Coke<T extends Taste> { }
class CherryCoke extends Coke<Cherry> { }
class x {
void drink() {
List<Coke<?>> xs = Arrays.asList(new CherryCoke());
}
}