Thanks Junky, and sorry if it was I who made you grumpy! :-)
I guess I expected that Java would instantiate a Panda, eg using the default no-arg constructor (which is provided) to allow the cast...
Type: Posts; User: roger1990
Thanks Junky, and sorry if it was I who made you grumpy! :-)
I guess I expected that Java would instantiate a Panda, eg using the default no-arg constructor (which is provided) to allow the cast...
Thanks Syed, but this gives a runtime class cast error...
Exception in thread "main" java.lang.ClassCastException: test.Animal cannot be cast to test.Panda
at test.test.main(test.java:7)
I have a base class with a factory method as follows. It looks for a database record and returns it if found, or creates it if not.
public class Animal {
public static Animal factory(String...