Javadoc & Documentation Comments
A Javadoc comment, delimited by /** and */ and placed directly above a class, method, or field, documents that piece of code in a structured format the javadoc command-line tool can extract and turn into browsable HTML documentation — precisely the same kind of official reference documentation the JDK's own classes ship with. Inside a Javadoc comment, special tags add structured detail: @param describes one method parameter, @return describes what a method gives back, @throws documents an exception the method might throw and under what condition, and @author or @since record authorship or version history.
Beyond the generated HTML, a well-written Javadoc comment is also what most IDEs display directly in a tooltip the moment a developer hovers over a method call, making good Javadoc comments genuinely useful even for a team that never runs the javadoc tool to generate a formal HTML site at all.
The comment syntax
/** ... */ placed directly above a class, method, or field marks it as a Javadoc comment.
The javadoc tool
Extracts these comments and generates browsable HTML reference documentation from them.
@param
Documents what one specific method parameter represents.
@return
Documents what a method's return value represents.
@throws
Documents a specific exception the method might throw, and under what condition it does.
public class JavadocDemo { /** * Calculates the square of a given number. * * @param n the number to square * @return the square of n */ static int square(int n) { return n * n; } public static void main(String[] args) { System.out.println("Square: " + square(6)); }}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Java yourself — building beats watching.