01. Javadocs Introduction

What is a Javadoc?

Javadocs allow you to generate HTML documentation from your source files. The online API documentation is the result of running a javadoc on the source code of a standard Java library, much like this HTML page here.

Declaring Javadocs

To declare a comment as a Javadoc, simply use one of the following notations:

/** Javadoc Comments */
 Javadoc Comments 
 *  Javadoc Comments

Anything that goes within these comments are valid for Javadoc. To attach the comments to our code, we place them directly before classes, constructors fields, interfaces and methods.

Javadoc Tags

Tags allow Javadoc to know what type of information will follow. Here is a list of common pre-defined tags:

@author [name]
The Author(s) for a class or interface.
@version [version]
The version of the class.
@param [name][desc]
describes an argument of a method or constructor.
@return [description]
Describes the data that is to be returned.
@exception [exc][desc]
Describes what exception can be thrown by method.
@since [version]
Which version you added this method.
@deprecated [desc]
Use if method or class is deprecated.
@see [hyperlink]
Reference some other javadoc.

Now that we know the fundamentals of declaring a javadoc and the tags that go with, let's learn how to apply them to a typical class.

Learn Enterprise Java Development for a Bright Career

Core Java, Volume II

Learn Enterprise Java Development for a Bright Career Try Java

Designed for serious programmers, this reliable, unbiased, no-nonsense tutorial illuminates advanced Java language and library features with thoroughly tested code examples. As in previous editions, all code is easy to understand and displays modern best-practice solutions to the realworld challenges faced by professional developers.

$ Check price
59.9959.99Amazon 4 logo(34+ reviews)

More Java resources

Take your Linux skills to the next level!

How Linux Works

Take your Linux skills to the next level! Try Linux & UNIX

In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.

$ Check price
39.9539.95Amazon 5 logo(114+ reviews)

More Linux & UNIX resources