How to make a abstract class with default comments on it?

我与影子孤独终老i 提交于 2021-02-10 14:14:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!