Method in Java interface that returns class or subclass type -
i have interface:
public interface displayable { public class <screen> classtodisplay(); }
and classes:
public class screen { } public class screensubclass extends screen { } public class cue implements displayable { @override displayclass() { return screensubclass.class; } }
i'm getting ide error telling me incompatible types. return value needed 'classtodisplay()' return class or subclass type of screen?
just figured out. use ? wildcard along 'extends'...
change return type 'displayclass' to:
public class<? extends screen> displayclass();
Comments
Post a Comment