如何在javadoc中引用私有静态最终常量值?

cdmah0mi  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(643)

我有一个类似于下面的类,在这里我想在描述时引用无效的/apple/orange常量 mCurrentFruit . 我不知道怎么做。

public class MyClass {

private static final int INVALID = -1;

private static final int APPLE = 1;

private static final int ORANGE = 2;

// Holds APPLE/ORANGE if currently chosen fruit is one among them, INVALID if user didn't choose anything
private int mCurrentFruit = 0;

    public MyClass() {
        //Do something here
    }
}

尝试{@link myclass.invalid}和{@value myclass.invalid}都无效。
如果有人帮忙,我们将不胜感激!

wj8zmpe1

wj8zmpe11#

使用 /**.... */ javadocs的块。
如何为javadoc工具编写文档注解

public class MyClass {

    private static final int INVALID = -1;

    private static final int APPLE = 1;

    private static final int ORANGE = 2;

    /**
     * Holds {@link MyClass#APPLE} or {@link MyClass#ORANGE} if currently chosen fruit is one among them
     * Otherwise, {@link MyClass#INVALID} if user didn't choose anything
     */
    private int mCurrentFruit = 0;

    public MyClass() {
        //Do something here
    }
}

相关问题