Search:

Type: Posts; User: roger1990

Search: Search took 0.23 seconds.

  1. Re: Type mismatch assigning factory class result to subclass

    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...
  2. Re: Type mismatch assigning factory class result to subclass

    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)
  3. Type mismatch assigning factory class result to subclass

    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...
Results 1 to 3 of 3