java

Java Comments


What is Comments?

 

Comments are used to provide explanations or annotations within the source code. Comments are ignored by the Java compiler and do not affect the execution of the program.

 

There are two types of comments in Java.

 1. Single-Line Comments  ( // ) 

// This is a single-line comment
int x = 10; // Here, x is a variable

 

2. Multi-Line Comments ( /*  ….   */ )

/*
  This is a multi-line comment
  Below, y is a variable that stored value 20
 */
int y = 20;