| Author |
ClassCastException going from interface to object
|
Alan Smithee
Greenhorn
Joined: Mar 21, 2006
Posts: 23
|
|
Given the class =================== public class AllStuff implements Serializable { public List <IBigCar> bigcars; } And the following code ======================= BigCar bc = new BigCar(); bc = (BigCar) this.classname.getAllStuff("uniqueID").getBigCarList().get(0); This code compiles. Why am I not able to cast an interface from a list to an object?
|
 |
Garrett Rowe
Ranch Hand
Joined: Jan 17, 2006
Posts: 1295
|
|
If the runtime type is actually a BigCar then the cast should work. If you are getting a ClassCastException, then the run time type must not be a BigCar.
|
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
|
 |
 |
|
|
subject: ClassCastException going from interface to object
|
|
|