Java Comments

Comments in Java allow you to describe the code. This makes the Java code easy to read. Whatever you add inside a comment never gets compiled. Comments in a Java program can be mentioned in the following two ways:

  • Single-line Comment
  • Multi-line Comments

Single-line comments

Use // i.e., two forward slashes for a single-line comment in Java. Whatever we mention after the slashes in a single line, will not get compiled.

Let us see an example displaying single-line comments in Java:

Output

Multi-line comments

For multi-line comments in Java, use /*     */. Whatever we mention under /* and */, will not get compiled.

Let us see an example displaying multi-line comments in Java:

Output



If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Read More

Install Java 21 on Windows 10
Java Type Casting
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading