- If you haven’t completed the Boolean exercise, do so now. Open BooleanSingle.java in an editor and add the following javadoc comments.
/** * An example of using a boolean method. * @author James A. Brannan * @version 1.0 * */ public class BooleanSingle{ /** * Tests if x is a single digit. * @param x the integer to test * @return true if x is single digit, false otherwise */ public static boolean isSingleDigit(int x){ if (x > -10 && x < 10){ return true; } else { return false; } } public static void main(String[] args){ boolean isSingleOne = BooleanSingle.isSingleDigit(4); boolean isSingleTwo = isSingleDigit(22); System.out.println("is 4 single digit: " + isSingleOne); System.out.println("is 22 single digit: " + isSingleTwo); } }
- In your current working directory, create a subdirectory named documentation
- Execute the javadoc command, specifying the output directory as documentation
$ javadoc BooleanSingle.java -d documentation Loading source file BooleanSingle.java... Constructing Javadoc information... Standard Doclet version 1.8.0_60 Building tree for all the packages and classes... Generating documentation/BooleanSingle.html... Generating documentation/package-frame.html... Generating documentation/package-summary.html... Generating documentation/package-tree.html... Generating documentation/constant-values.html... Building index for all the packages and classes... Generating documentation/overview-tree.html... Generating documentation/index-all.html... Generating documentation/deprecated-list.html... Building index for all classes... Generating documentation/allclasses-frame.html... Generating documentation/allclasses-noframe.html... Generating documentation/index.html... Generating documentation/help-doc.html...
- Open your browser and open index.html and you should see the generated java documentation.