posted 16 years ago
Only line 2 will give you warning,
As it is assigning raw collection to parameterized collection, and raw collection could be of any type, Bus, Truck, Train that could claim ClassCastException at runtime when it will try to return Bus and it is containing Truck, so only line 2 will give warning.
Line 1 is safe as you are assigning to a raw ArrayList that could take any type of ArrayList as no parameter bound, so no ClassCastException as it will always return Object.