Javadoc {@value} 不适用于常量

问题描述

我正在尝试将 Javadoc 应用于常量变量。

代码

private final String playerName;

/**
 * The value of MAX_PLAYER_HEALTH is {@value} 
 */
 
private static final Integer MAX_PLAYER_HEALTH = 200;

/**
 * The value of DEFAULT_PLAYER_LIVES {@value}
 */
private static final Integer DEFAULT_PLAYER_LIVES = 3;

private Integer health = MAX_PLAYER_HEALTH;
private int lives = DEFAULT_PLAYER_LIVES;

有了这个,一旦我生成了 Javadoc,我就会收到一个错误

C:\Users\Amirs\OneDrive\Documents\NetBeansprojects\Thetower\src\PlayerSingleton\PlayerSingleton.java:22: error: {@value} not allowed here
     * The value of DEFAULT_PLAYER_LIVES {@value}
C:\Users\Amirs\OneDrive\Documents\NetBeansprojects\Thetower\src\PlayerSingleton\PlayerSingleton.java:18: error: {@value} not allowed here
     * The value of MAX_PLAYER_HEALTH is {@value}

我正在关注 Oracle 上的 reference guide。我做错了什么?

更新代码:将 Integer 更改为 int{@value} 只能用于原始类型,不能用于包装器,例如 Integer

解决方法

问题是在常量变量中使用 Integer 而不是 int