Hi,
I have the following two classes defined in separate files:
public abstract class Barn<TAnimal extends Animal>
{
public abstract TAnimal createNewAnimal();
}
public class MyBarn extends Barn<TAnimal extends Animal>
{
public TAnimal createNewAnimal()
{
return new Horse(); // Horse extends Animal.
}
}
Now the above gives me an error about not being able to convert a Horse to a TAnimal. I can just change it to this:
return (TAnimal)(new Horse());
and it will compile but give me a type check safety warning. Is there some other way to do it to get rid of the warning? Everything makes sense to me, ie. all the classes derive properly to, in my mind, work as expected (though that really is irrelvant!),
Thanks
Start Free Trial