Java Documentation Comments Example

Introduction

Here is an example of a documentation comment for a class:

import java.io.IOException;

/**/*ww w  . ja  v  a 2s  .  c om*/
 * This class draws a chart.
 * 
 * @author demo2s
 * @version 1.2
 */

public class Main {
  /**
   * This method returns the square of num. 
   * This is a multiline description. 
   *
   * Another line
   * 
   * @param num
   *          The value to be squared.
   * @return num squared.
   */
  public double square(double num) {
    return num * num;
  }

  /**
   * This method inputs a number from the user.
   * 
   * @return The value input as a double.
   * @exception IOException
   *              On input error.
   * @see IOException
   */
  public double getNumber() throws IOException {
    // create a BufferedReader using System.in

    return 0;
  }

  /**
   * This method demonstrates square().
   * 
   * @param args
   *          Unused.
   * @exception IOException
   *              On input error.
   * @see IOException
   */

  public static void main(String args[]) throws IOException {

  }
}



PreviousNext

Related