如何制作一个带有默认注释的抽象类? [英] How to make a abstract class with default comments on it?
本文介绍了如何制作一个带有默认注释的抽象类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有抽象方法的超类,我想对该方法提供一些注释,如果有任何子类继承了该方法,则此注释将随之而来.
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() {
}
}
推荐答案
你需要添加适当的 java-doc 注释,这样实现类才会得到这些注释.
You need to add proper java-doc comments, than that implementing class will get those.
这个技术也用在 jdk 内部的不同地方——方法被继承只是为了获取它们的文档.
This technique is used in various places inside the jdk too - methods are inherited only to get their documentation.
这篇关于如何制作一个带有默认注释的抽象类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文