Java Supports 3 types of comments in coding

  1. Single-line comment.
  2. Multi-line comment.
  3. Documentation comment.

PFB the detailed description of the types with example.

Single-line comment

//Line1  - Single line comment 
Eclipse IDE key-board shortcut : Keep the cursor in the exact line and press ctrl+/

Multi-line comment

Line 2*/ 
Eclipse IDE key-board shortcut :Selected the lines and press this key Ctrl+shift+/

Documentation comment

*Line 1 
*@author : karthik
*@since : 2016 */

This indicates documentation comment (java doc) . The JDK javadoc tool uses doc comments when preparing automatically generated documentation. For more information on javadoc, see the Java tool documentation.

(Note : Please look the notation carefully, this has 2asteriks symbol at the begining)

Eclipse IDE key-board shortcut : ctrl+alt+j

Documentation comment have an in-built parameter specification which can be used by developer to input, so that java generator will be able to append these meta data for better clarity.

 Parameter Description
@author karthik Describes an author.
@version Version 2.1 Display software version.
@since date/text Describes when this functionality was added
@see reference to other element of documentation. Can be a link or piece of code
@param UserName ,encryptedPassword Describes a method parameter.
@return boolean Describes the return value.
@exception classname description
@throws classname description
Exception that may be thrown from this method.
@deprecated description Describes an deprecated method.
{@inheritDoc} Copies the description from the overridden method.
{@link reference} Reference Link.
{@value #STATIC_FIELD} Value of a static field.
{@code literal} It is similar to <code>{@literal}</code>.
{@literal literal} The enclosed text is interpreted as not containing HTML markup or nested javadoc tags.


Add comment
  • No comments found