VOOZH about

URL: https://www.geeksforgeeks.org/java/comments-in-java/

⇱ Java Comments - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Comments

Last Updated : 13 Oct, 2025

In Java, comments are non-executable statements that explain code and improve readability. They are ignored by the compiler and do not affect program execution.

  • Enhance code readability and maintainability.
  • Useful for debugging and documenting logic.

Java supports three main types of comments:

1. Single-Line Comments

Single-line comments are used to comment on one line of code.

Syntax:

// Comments here( Text in this line only is considered as comment )


Output
Single Line Comment Above

2. Multi-Line Comments

Multi-line comments are used to describe complex code or methods, as writing multiple single-line comments can be tedious.

/*
Comment starts
continues
continues...
Comment ends
*/


Output
Multi Line Comments Below

3. Documentation Comments

Documentation comments are used to generate external documentation using Javadoc. They are generally used in professional projects to describe classes, methods, and parameters.

Syntax:

/**
* Comment start
* @param param-name description
* @return description
*/


Output
Average of 10, 20, and 30 is: 20

Related Article: JavaDoc tool


Comment
Article Tags:
Article Tags: