Saturday 20 January 2018

Javadoc: @exception: Specify the exception thrown by a method

@exception tag is used to specify the exception thrown by a method (or) constructor.

Syntax
@exception Exception_Class_Name

What is the difference between @throws and @exception tags?
No difference, both are identical (synonyms).

Arithmetic.java
package com.java.tags;

/**
 * 
 * @author Hari Krishna
 * 
 * @since 1.0
 */
public interface Arithmetic {

 /**
  * The value of PI is {@value}
  */
 public static final double PI = 3.14;

 /**
  * 
  * @param radius
  *            radius of the circle
  * 
  * @return area of the circle
  * 
  * @exception IllegalArgumentException
  *                thrown if radius < 0.
  */
 public double areaOfCircle(int radius) throws IllegalArgumentException;

}

When you generate javadoc, it looks like below.




Previous                                                 Next                                                 Home

No comments:

Post a Comment