Java Comments

We can add comments in java code. They are not compiled. Java compiler simply ignores the java comments and only compiles the java code. There are two types of java comments.

Single line java comments

Multiline java comments

Single line java comments

Any line in java code starting with // is a java comment and java compile will ignore it while compiling.
Following example shows a single line java comment:

// This is a comment
System.out.println("Hello World");

We can add java comments at the end of a java code statement. Following example shows a single line java comment at the end of a java code statement:

System.out.println("Hello World"); // This is a comment

Java Multi-line Comments

We can add comments in a java program which span more than one lines.

Multi-line comments start with /* and ends with */. Any text between /* and */ will be ignored by Java.
Following example shows multi-line java comments:

/* It is a multi-line java comment
It is second line of java comment
It is third line of java comment
You can add as much lines of java comments as you want */
System.out.println("Hello World");