Foo.java
1    package demo;
2    
3    /**
4     * A widget for demonstration of <b>Javadoc</b>.
5     */
6    public class Foo {
7        /* no fields */
8    
9        /**
10        * Prints information indicating that the constructor has been called.
11        */
12       public Foo() {
13           System.out.println("new Foo();");
14       }
15   
16       /**
17        * Prints information indicating that bar(x) has been called.
18        * @param x Determines value printed between the parens.
19        * @throws IllegalArgumentException if x &lt; 0.
20        * @return "baz"
21        */
22       public String bar(int x) {
23           if (x < 0) {
24               throw new IllegalArgumentException(
25                       "bar called with negative input.");
26           }
27           // see: PrintStream.format - the "%d" is replaced with the value of x.
28           System.out.format("bar(%d);\n", x);
29           return "baz";
30       }
31   }
32