问题
I have a superclass with an abstract method I want to provide some comments on the method and if any subclasses inherited this method this comments will come along with it.
class MySuper {
//some comments
protected abstract void myAbstractMethod();
}
class MyChild extends MySuper {
//some comments
@Override
public void updateLanguage() {
}
}
回答1:
You need to add proper java-doc comments, than that implementing class will get those.
This technique is used in various places inside the jdk too - methods are inherited only to get their documentation.
回答2:
When defining an abstract method you should use java-doc to help someone who will have to write the implementation.
On the extending class, I would expect to find a java-doc explaining this very implementation.
来源:https://stackoverflow.com/questions/56111642/how-to-make-a-abstract-class-with-default-comments-on-it