hi there
i got a program using corba. however this is a problem i got when pulling objects out of an arraylist i create.
i create the arraylist and i put (to test) 1 object in it. as far as i know the object i put in it is type "Object" after i did list.add(myObject).
now i have a method to get the object out of the arraylist again that looks like this:
public Car getCar(ID){}
due to the fact that i'm working with corba i can not instantiate the Car object because it's an abstract class. now when i do list.get(listspot) i get an "Object" object. but to be able to return it i have to put that into a Car object. if i dont do this the compiler will not work
i do have an implementation class of Car called CarImp.
i tried to do something like this:
public Car getCar(listspot){
CarImp theCar = (CarImp) list.get(listspot);
return theCar;
}
this will not work because here a "CarImp" object is returned instead of a "Car" object.
the question here is if there's any way to turn the CarImp object into a Car object or make the compiler think so?
i got a program using corba. however this is a problem i got when pulling objects out of an arraylist i create.
i create the arraylist and i put (to test) 1 object in it. as far as i know the object i put in it is type "Object" after i did list.add(myObject).
now i have a method to get the object out of the arraylist again that looks like this:
public Car getCar(ID){}
due to the fact that i'm working with corba i can not instantiate the Car object because it's an abstract class. now when i do list.get(listspot) i get an "Object" object. but to be able to return it i have to put that into a Car object. if i dont do this the compiler will not work
i do have an implementation class of Car called CarImp.
i tried to do something like this:
public Car getCar(listspot){
CarImp theCar = (CarImp) list.get(listspot);
return theCar;
}
this will not work because here a "CarImp" object is returned instead of a "Car" object.
the question here is if there's any way to turn the CarImp object into a Car object or make the compiler think so?