Comments in java code

Previous
Next

Comments are the essential part of code. If you write good comments, it will be easier for others to understand the code. Comments are ignored by the compiler when it compiles the program.

There are three types of comments in java code.

  1. Single line comments
  2. Multi-line comments
  3. Java doc comments

Single line comments:

These are most used java comments. It is used to comment a single line.

For example:

Multi line comments:

If you want to write comments in multiple line, single lines comments may be tedious to write.In this situation, you can use multi line comments.

For example:

Javadoc comments:

If you want to generate javadoc for your class, you can use javadoc comments. When you run javadoc command, it automatically generate javadoc with javadoc comments

For example:

Comments are most important part of code. You should use them as and when required.

Previous
Next

Join Our News Letter – Stay Updated

Subscribe to Awesome Java Content.




Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog