Javadoc: Difference between revisions

Content deleted Content added
Design: Remove recommendations since subjective and how-to-y
collect all examples together
Line 70:
*/
private int debug = 0;
</syntaxhighlight>
 
A more complete example follows:
 
<syntaxhighlight lang="java">
/**
* Validates a chess move.
*
* <p>Use {@link #doMove(int fromFile, int fromRank, int toFile, int toRank)} to move a piece.
*
* @param fromFile file from which a piece is being moved
* @param fromRank rank from which a piece is being moved
* @param toFile file to which a piece is being moved
* @param toRank rank to which a piece is being moved
* @return true if the move is valid, otherwise false
* @since 1.0
*/
boolean isValidMove(int fromFile, int fromRank, int toFile, int toRank) { ... }
 
/**
* Moves a chess piece.
*
* @see java.math.RoundingMode
*/
void doMove(int fromFile, int fromRank, int toFile, int toRank) { ... }
</syntaxhighlight>
 
Line 133 ⟶ 158:
|
|}
 
=== Examples ===
 
An example of Javadoc to document a method follows. Notice that spacing and number of characters in this example are as conventions state{{Clarify|date=September 2024}}.
<syntaxhighlight lang="java">
/**
* Validates a chess move.
*
* <p>Use {@link #doMove(int fromFile, int fromRank, int toFile, int toRank)} to move a piece.
*
* @param fromFile file from which a piece is being moved
* @param fromRank rank from which a piece is being moved
* @param toFile file to which a piece is being moved
* @param toRank rank to which a piece is being moved
* @return true if the move is valid, otherwise false
* @since 1.0
*/
boolean isValidMove(int fromFile, int fromRank, int toFile, int toRank) {
// ...body
}
 
/**
* Moves a chess piece.
*
* @see java.math.RoundingMode
*/
void doMove(int fromFile, int fromRank, int toFile, int toRank) {
// ...body
}
</syntaxhighlight>
 
== Doclets ==