Comments in Java

Comments in Java

Mar 02, 2022

Comments in Java is important, so that other developers can easily read and understand your code. Comment implementations are intended for commenting out code or commenting on how the code works in a specific implementation. Comments give extra information if the code is difficult for other developers to understand.

How to write comments in Java

It is simple to write comments in Java, you only need to understand the different types of comments in Java before you begin commenting your Java code. These types of comments are simple to learn and understand. Learn more below.

Types of comments in Java

These are the 3 types of comments in Java; Single-lineMulti-line, and Documentation comments. These comments are important and easy to learn and remember, especially for you as a beginner.

Single-Line Comment

Single-line comments start with two forward slashes //. Java will ignore any text after the two forward slashes. This means that Java will not execute the text after these forward slashes. The Single-Line comment is widely used and easy to implement. Simply type the two forward slashes.

Multi-Line Comment

Multi-Line Comment is another name for (Block Comments). Multi-Line comments are used to describe files or to provide more explanation to the code. Java will ignore any text between /* and */. This means that the text between /* and */ will not be executed by Java.

Read more comments in Java

Enjoy this post?

Buy Kensoft PH a glass of milk

More from Kensoft PH