如何为getInstance方法编写Javadoc?

Ric*_*ral 4 java javadoc intellij-idea

说我有这样的事情:

public class MyClass {
    private static MyClass sInstance;

    /**
     *
     * @return The {@link MyClass} application instance.
     */
    public static MyClass getInstance() {
        return sInstance;
    }
}
Run Code Online (Sandbox Code Playgroud)

IntelliJ给了我这个警告:

'@link'指向包含类是不必要的

编写这片Javadoc的正确/传统方式是什么?

你会怎么写的?

Thi*_*ilo 5

在JDK中,他们使用{@code}.这不会产生可点击的链接,但您已经在查看将要链接的页面.

例如(来自String.java):

  /**
  * Initializes a newly created {@code String} object so that it represents
  * the same sequence of characters as the argument; in other words, the
  * newly created string is a copy of the argument string. Unless an
  * explicit copy of {@code original} is needed, use of this constructor is
  * unnecessary since Strings are immutable.
  *
  * @param  original
  *         A {@code String}
  */
Run Code Online (Sandbox Code Playgroud)