Skip to content

Tag: type-erasure

Why java lets me add a Box(Raw type) to a List<Box>

This code works, and I dont understand how the list is able to add a raw type box, I thought type erasure will set the type to their indicated bounds. note: Paper class doesn’t extends Bakery class. EDIT: Is my understanding correct? the compiler typecasts the raw box type so that it can be added to the list? does this