java - 为什么默认构造函数总是出现在 javadoc 文档中,即使它不存在于代码中?

标签 java javadoc

为什么默认构造函数总是出现在 javadoc 文档中,即使代码中不存在?

一种可能的补救措施是显式编写默认构造函数,即使我不需要它,只需向其添加注释“仅供内部使用”或类似的内容...

谢谢

最佳答案

根据http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html :

The compiler automatically provides a no-argument, default constructor for any class without constructors

这意味着,默认构造函数将在编译时隐式添加。当时,当它获取javadoc时,它已经被添加了。 这是在这里指定的 http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#defaultconstructors :

Section 8.8.7 of the Java Language Specification, Second Edition describes a default constructor: If a class contains no constructor declarations, then a default constructor that takes no parameters is automatically provided. It invokes the superclass constructor with no arguments. The constructor has the same access as its class.
The Javadoc tool generates documentation for default constructors. When it documents such a constructor, Javadoc leaves its description blank, because a default constructor can have no doc comment. 

关于java - 为什么默认构造函数总是出现在 javadoc 文档中,即使它不存在于代码中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17708944/

相关文章:

java - 从 java 文档生成代码

java - 寻找具有 Javadoc 注释的 Java 代码的好示例

java - 模块包括 ibm-web-bnd.xml 和 ibm-web-ext.xml 文件。当错误 401、404 等发生时,如何显示 Error.jsp 文件?

java - 让 Eclipse 警告性能错误

javadoc - 链接到现有 javadoc 仅适用于 Java 平台包

Eclipse - 强制 Javadoc 悬停在有警告的元素上

intellij-idea - 如何在IntelliJ Idea中设置外部库的javadoc?

java - "Maximum Depth of Binary Tree"的递归方法(Java)的时间复杂度是多少?

java - 如何使用 apache POI 在 ppt 中将长表拆分为多张幻灯片

java - Spring MVC 4.0 - Web Config 中的 Hibernate OpenSessioninViewFilter