Previous Next

Java Comments

Comments are utilized in Java to improve the readability and comprehensibility of the code to developers.

Single Line Comments

Example:

public class Main {
  public static void main(String[] args) {
   // This is a single line comment
  System.out.println("Hello Coders!");
  }
}

Output

Hello Coders!

Multi-line comments

Example:

public class Main {
  public static void main(String[] args) {
   /* This is a
   multi line
   comment */

  System.out.println("Hello Coders!");
  }
}

Output

Hello Coders!
Previous Next