Java Comments - The Coding Shala

Home >> Learn Java >> Java Comments

Java Comments

In every programming, language comments are used for understanding the program. Comments are human-readable and ignored by the compiler. In Java there are three types of comments:

1. Single-line comments

2. Multi-line comments

3. Documentation comments

Java Comments - The Coding Shala

Single-line and Multi-line comments are often used in programs. 

Single-Line Comments


Single-line comments are used to comment single in the program. Single-line comment starts from //.

Multi-Line Comments

Multi-line comments are used to comment more than one line at once. Using multi-line comments we can comment single line or a part of the program. Multi-line comments start with /* and end with */ and between this every line ignored by the compiler. 
public class CommentsExample{
    public static void main(String[] args){
        System.out.println("Single line comment here");
        //this is single line comment
        /* multi-line comment starts here
        int i = 0;  ignored by compiler 
        continue multi-line here
        end of multi-line comments */
        System.out.println("Hello there");
    }
}


<<<<<<<<<<<<Output>>>>>>>..
Single line comment here
Hello there



Other Posts You May Like
Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Comments

Popular Posts from this Blog

Java Program to Convert Binary to Decimal - The Coding Shala

N-th Tribonacci Number Solution - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Shell Script to find sum, product and average of given numbers - The Coding Shala

Java Program to Convert Decimal to Binary - The Coding Shala