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
Post a Comment