子类在 javadocs 中不可见

问题描述 投票:0回答:1

我尝试为扩展另一个类的抽象类创建javadocs。但是在javadoc树中,子类不可见。我使用intellij-idea来完成此操作,并使用src>javadoc GraphicObject.java生成javadoc 在终端中。我想将树生成为,

- GraphicObject
  - Rectangle 

但它仅显示,


/\*\*
\*
\*
*/
public abstract class GraphicObject {
/*\*
\* The x-coordinate of the graphic object.
*/
protected int x;
/*\*
\* The y-coordinate of the graphic object.
*/
protected int y;
/*\*
\* The width of the graphic object.
*/
protected int width;
/*\*
\* The height of the graphic object.
*/
protected int height;
/*\*
\* Constructs a new graphic object with the specified coordinates, width, and
\* height.
\*
\* @param x the x-coordinate
\* @param y the y-coordinate
\* @param width the width
\* @param height the height
*/
public GraphicObject(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
/*\*
\* Moves the graphic object to the specified coordinates.
\*
\* @param x the new x-coordinate
\* @param y the new y-coordinate
\*/
public abstract void move(int x, int y);

}
/\*\*

* This is a subclass of GraphicObject that represents a rectangle.
* 
* 
* @see GraphicObject "This class extends GraphicObject."
  \*/
  class Rectangle extends GraphicObject {
  public Rectangle(int x, int y, int width, int height) {
  super(x, y, width, height);
  }
  @Override
  public void move(int x, int y) {
  this.x = x;
  this.y = y;
  }
  }
java intellij-idea javadoc
1个回答
0
投票

javadoc 不显示您的

Rectangle
类的原因是该类受包保护(即,它没有任何可见性修饰符),并且默认情况下 javadoc 命令仅显示公共或受保护的类。您可以通过在命令行中提供特定选项 –
-package
– 或在 IntelliJ 的下拉列表中选择正确的项目来更改此行为。

当然,如果

Rectangle
子类应该是公共的,则应该将其移动到专用的新文件中

© www.soinside.com 2019 - 2024. All rights reserved.