e Learning

Types of Comments in Java

All Programming languages use comments, so is Java. Mainly Java has Three Type of comments.

Single Line Comments

Anything after Two Forward Slashes at any single line consider as a single line comment in Java.


//This is a Single line comments in Java, And the Compiler will simply ignore this line.

Multiline Comments

Multi Line comments start with a forward slash and star (/*) and ends with a star and a forward slash (*/). Any text between consider as Comments in Java.



This an example of multi line comment

And This can go to multiple line as long as

It stays between “/*” and “*/”

The Compiler will ignore these lines too.


Documentation Comment

Documentation comments are almost same as multi line comments only difference is it start with forward slash and two stars(/**)



This is an example of a Javadoc comments

Startswith /**

and ends with */


Ok! That is About Three Types of Comments You can Find in Java Programming Language.