java - How to force implementing a method of a class, without declaring the whole class abstract? -


i make base class (most time base class activity) extended other classes in project.

how can force clients implement method?

i cannot make 1 method abstract without making whole class abstract.

make class abstract. if want force implementation, you're not going want instatiate base class anyway. other methods can still have concrete implementations, follows;

public abstract class serverlisthtml extends httpservlet {     abstract public void foo();     public int concrete() {         return 0;     }  } 

you can define own instantiable subclass if need basic "default" set of functionality.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -