152

is there a good example of a source file containing Javadoc?

I can find lots of good examples of Javadoc on the internet, I would just like to find out the particular syntax used to create them, and assume I can pore through the source of some library somewhere but that seems like a lot of work.

Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
Jason S
  • 184,598
  • 164
  • 608
  • 970

11 Answers11

125

How about the JDK source code, but accessed through a 3rd party like docjar? For example, the Collections source.

That way, there's no big download.

GaryF
  • 23,950
  • 10
  • 60
  • 73
39

The page How to Write Doc Coments for the Javadoc Tool contains a good number of good examples. One section is called Examples of Doc Comments and contains quite a few usages.

Also, the Javadoc FAQ contains some more examples to illustrate the answers.

rluba
  • 2,014
  • 2
  • 19
  • 26
Jared Oberhaus
  • 14,547
  • 4
  • 56
  • 55
10

How about the JDK source code?

Abhijeet
  • 8,561
  • 5
  • 70
  • 76
butterchicken
  • 13,583
  • 2
  • 33
  • 43
6

I use a small set of documentation patterns:

  • always documenting about thread-safety
  • always documenting immutability
  • javadoc with examples (like Formatter)
  • @Deprecation with WHY and HOW to replace the annotated element
dfa
  • 114,442
  • 31
  • 189
  • 228
5

Have a look at Spring framework source, it has excellent javadocs

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49
4

ANT for example - source code browsable online: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DefaultLogger.java?view=co

To choose other files start from: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/?pathrev=761528

hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
Nick Fortescue
  • 43,045
  • 26
  • 106
  • 134
4

The documentation of Google Guava's EventBus package and classes is a good example of Javadoc. Especially the package documentation with the quick start is well written.

Marvin Frommhold
  • 1,040
  • 8
  • 7
2

Download the sources of Lucene and see how they do it. They have good JavaDocs.

RichieHindle
  • 272,464
  • 47
  • 358
  • 399
2

If all your looking for is the syntax, then this may help:

How to Write Doc Comments for the Javadoc Tool

Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
Jesse
  • 1,485
  • 1
  • 12
  • 21
2

If you are using Eclipse, then you can setup your JDK (not JRE) in Installed JREs, and then use Open Type (Ctrl + Shift + T), give something like java.util.Collections

Jason S
  • 184,598
  • 164
  • 608
  • 970
KrishPrabakar
  • 2,824
  • 2
  • 31
  • 44
  • 1
    To add to what was said, most IDEs automatically configure javadocs and source when you configure the JDK for them to use. This does not only apply to Eclipse. – ThePyroEagle May 04 '16 at 19:40
1

If you install a JDK and choose to install sources too, the src.zip contains the source of ALL the public Java classes. Most of these have pretty good javadoc.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347