I try to make javadocs for an abstract class that extends another class.but in the javadoc tree, the subclass is not visible.I used intellij-idea for done this and I got generate javadoc using src>javadoc GraphicObject.java in terminal.I want to generate the tree as,
- GraphicObject
- Rectangle
but it shows only,
/\*\*
\*
\*
*/
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;
}
}
The reason why the javadoc isn't showing your Rectangle
class is because the class is package-private (i.e., it doesn't have any visibility modifier) and by default the javadoc command only shows public or protected classes. From the documentation (this is for JDK8, but it's the same in JDK 20 and – I assume – all the versions in between):
The javadoc command [...] produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields
You can change this behaviour by supplying a specific option in the command line – -package
– or by selecting the right item in the drop-down in IntelliJ.
Of course, if the Rectangle
subclass is supposed to be public, it should be moved to a dedicated new file