Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between /* ...*/ and /** ... */

I've noticed that Eclipse prints diferent formats to comments:

/* Eclipse prints it in green 
*/

or if you write:

/** Eclipse prints it in blue
*/

What is the difference between these 2 kind of comments?

like image 553
Juliatzin Avatar asked Dec 19 '22 09:12

Juliatzin


1 Answers

/* 
* It is multi-line comment in Java
*
*/

/** 
* It is a Javadoc. Can be found above methods and Class definitions.
*
*
*/

Here is a excerpt from Wikipedia regarding Javadoc:

A Javadoc comment is set off from code by standard multi-line comment tags /* and */. The opening tag (called begin-comment delimiter), has an extra asterisk, as in /**.

The first paragraph is a description of the method documented.
Following the description are a varying number of descriptive tags, signifying:
    The parameters of the method (@param)
    What the method returns (@return)
    Any exceptions the method may throw (@throws)
    Other less-common tags such as @see (a "see also" tag)

Class level Javadoc Example:

/**
 * @author      Firstname Lastname <address @ example.com>
 * @version     1.6                 (current version number of program)
 * @since       2010-03-31          (the version of the package this class was first added to)
 */
public class Test {
    // class body
}

Method level Javadoc Example:

/**
 * Short one line description.                           
 * <p>
 * Longer description. If there were any, it would be    
 * here.
 * <p>
 * And even more explanations to follow in consecutive
 * paragraphs separated by HTML paragraph breaks.
 *
 * @param  variable Description text text text.          
 * @return Description text text text.
 */
public int methodName (...) {
    // method body with a return statement
}
like image 180
nebula Avatar answered Jan 01 '23 16:01

nebula