3) ArrayList b = a; This assignment assigns a typesafe arraylist in to a non-typesafe arraylist, So this assignment causes warning during compilation.
=============================================================================== When I wrote this program, I got compile error because "Incompatible cast(ArrayList<Car> to (ArrayList<Bus> ". Even the answer which they have given is also conflict. Can anybody help me?
Hi Changra, Thanks for explanation. I got your point. But my question was, I got compiler error, and they have given answer is little conflict. As they have given answer 3, but that conflicts with their explanation.
Joined: Feb 28, 2007
Ref variable b refers to ArrayList object parameterized with Car. Now you are trying to cast that object to a ArrayList ref variable that is parameterized with Bus. Against the rule of generics. This sort of casting is not possible using generics.