How to reference a method in javadoc?

To reference a method in Javadoc, you can use the {@link} tag.

For example, if you want to reference the toString() method of the Object class in Javadoc, you can use the following syntax:

{@link java.lang.Object#toString()}

This will create a hyperlink to the toString() method in the generated Javadoc HTML.

You can also use the {@linkplain} tag to create a hyperlink that is formatted like normal text, rather than being highlighted as a link.

For example:

{@linkplain java.lang.Object#toString()}

This will create a hyperlink to the toString() method that is formatted like normal text, rather than being highlighted as a link.

You can also use the {@inheritDoc} tag to inherit the documentation of a method from a superclass or interface.

For example:

/**
 * {@inheritDoc}
 */
public String toString() {
    // Method implementation
}

This will include the documentation of the toString() method from the superclass or interface in the generated Javadoc HTML.