Javadoc annotations consist of Javadoc tags and descriptive text, you can add comments for classes, interfaces, or elements in classes such as constructors, ranges, methods, and so on. Let's take a look at a program with Javadoc annotation, whose code looks like this:
Code Listing 1 Person.java
1.package Javadoc;
2.import java.io.Serializable; The
3./**
4.* <pre> Descriptor object, which has two attributes, is the name and gender. </pre>
5.* @see javadoc.tool.Car
6.* @version 1.0, 2005-04-12
7.* @author Chen Xionghua
8.* @since JDK1.3
9.*/
10.public class person implements Serializable
11.{
12./** male with a value of {@value}*/
13.public static final int MALE = 1;
14./** Female, value {@value}*/
15.public static final int FEMALE = 2;
16./** name */
17.protected String name;
18./** Age */
19.protected int sex;
20./**
21.* Constructs a person instance. Set the name and sex of person.
22.*
23.* @param name String name
24.* @param sex int Gender, valid value is {@link #MALE male} and {@link #FEMALE}
25.* @throws Personargumentexception
26.* @see javadoc.tool.car#drive (int)
27.*/
28.public person (String name, int sex) Throws Personargumentexception
29.{
30.if (sex!= MALE && sex!= FEMALE)
31.throw new Personargumentexception ("incorrect parameter");
32.this.name = name;
33.this.sex = sex;
34.} The
35./**
36.* Gets the gender code.
37.* @return int
38.* @see MALE
39.* @see FEMALE
40.*/
41.public int getsex ()
42.{
43.return sex;
45./**
46.* set gender
47.* @param sex int
48.*/
49.public void setsex (int sex)
50.{
51.this.sex = sex;
.}