This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.