技能 编程开发 Java Javadoc最佳实践指南

Java Javadoc最佳实践指南

v20260410
java-docs
本指南详细介绍了使用Javadoc注释书写Java代码的最佳实践规范。它涵盖了如何为公共、受保护、包私有及私有成员进行准确记录,并指导了各种标签(如@param, @return, @throws, @see)以及代码片段和版本控制的正确使用方法。遵循这些规范,能确保Java代码的API文档准确、可维护,符合专业开发标准。
获取技能
205 次下载
概览

Java Documentation (Javadoc) Best Practices

  • Public and protected members should be documented with Javadoc comments.
  • It is encouraged to document package-private and private members as well, especially if they are complex or not self-explanatory.
  • The first sentence of the Javadoc comment is the summary description. It should be a concise overview of what the method does and end with a period.
  • Use @param for method parameters. The description starts with a lowercase letter and does not end with a period.
  • Use @return for method return values.
  • Use @throws or @exception to document exceptions thrown by methods.
  • Use @see for references to other types or members.
  • Use {@inheritDoc} to inherit documentation from base classes or interfaces.
    • Unless there is major behavior change, in which case you should document the differences.
  • Use @param <T> for type parameters in generic types or methods.
  • Use {@code} for inline code snippets.
  • Use <pre>{@code ... }</pre> for code blocks.
  • Use @since to indicate when the feature was introduced (e.g., version number).
  • Use @version to specify the version of the member.
  • Use @author to specify the author of the code.
  • Use @deprecated to mark a member as deprecated and provide an alternative.
信息
Category 编程开发
Name java-docs
版本 v20260410
大小 1.41KB
更新时间 2026-04-12
语言