Java Reference
In-Depth Information
Problem
You want to document some of your Java classes to assist in future maintenance.
Solution
Use Javadoc to place comments before any class, method, or field that you want to
document. To begin such a comment, write the characters /** . Then begin each subse-
quent line with an asterisk ( * ). Lastly, close the comment with the characters */ on a
line by themselves at the end. Listing 1-8 shows a method commented with Javadoc.
Listing 1-8 . Comments Made in Javadoc Form
package org.java8recipes.chapter01.recipe1_08;
import java.math.BigInteger;
public class JavadocExample {
/**
* Accepts an unlimited number of values and
* returns the sum.
*
* @param nums Must be an array of BigInteger values.
* @return Sum of all numbers in the array.
*/
public static BigInteger addNumbers(BigInteger[]
nums) {
BigInteger result = new BigInteger("0");
for (BigInteger num:nums){
result = result.add(num);
}
return result;
}
/**
Test the addNumbers method.
* @param args not used
 
 
Search WWH ::




Custom Search