elibraryportal Logo

Comments in Java

comments are used to hide the program code, such as It provide the information or explanation about the variable, method, class or any statement.

Types of Comment in Java

  1. Single Line Comment
  2. Multi Line Comment
  3. Documentation Comment

1) Single Line Comment in Java

Double forward slash are used in a single line that is called Single line comment is Single Line Comments (SLC).

Syntax:

Example:

Output

Single Line Comment statement in java

2) Multi Line Comment in Java

Multi line comment is used to comment multiple lines of code.

Syntax:

Example:

Output

Single Line Comment statement in java

3) Documentation Comment in java

Documentation comment is used to create documentation API. To create documentation API, you need to use javadoc tool.

Syntax:

Example: