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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -