List<FlightOffer> flightOffers
It clearly defines what you can add to the list: instances FlightOffer
. flightOffers.add(new BaseOffer());
therefore, it cannot work, since a is BaseOffer
not FlightOffer
.
So why does it work hotelOffers.add(new BaseOffer());
? Since you disable generic type checks using the original type Hotel
in Hotel hotelObject = new Hotel<String>();
.
, : . , - , " " .
Edit:
, JLS ( 4.8):
, .
, Hotel
, , .. hotelOffers
, raw List
, ( hotelObject.hotelOffers.add("I'm not a hotel offer");
)