"KEEP LEARNING, DON'T STOP."
"KEEP LEARNING, DON'T STOP."
Java program contain group of statement. All statement execute in program but some of the statement not execute. That are called comment statement. Comment are the Java program statement which will not execute. We can also say it None-Executable statement.
Why we make comment in program that question come in beginners mind. Basically comment are used to provide the some useful information or some small documentation about the program. Most of the time we use comment statement in large program.
In Java language we have three types comments.
To make the single line comment we use two backword slash // symbol. This is called single line comment statement. In this program we are giving the information about the program by comment section. Comment section never will execute.
Now see the program code. By comment we are giving the information about the program logic. Like we are "Printing the message".
class Hello { public static void main(String args[]) { //Printing the message System.out.println("Welcome to campuslife"); } }
Welcome to campuslife
To make the Multiline comment we use two backword slash with two astric symbol /* */. This is called multiline comment statement. In this program we are giving the information about the program by comment section. Comment section never will execute.
Now in this program code we are making multiline comment by giving more information.
class Hello { public static void main(String args[]) { /*Printing the message and show on the console window*/ System.out.println("Welcome to campuslife"); } }
Welcome to campuslife
Documentation comment is used to create own API ( Application Programming Interface) document. To make the documentation comment we use two backword slash with three astric symbol /** */. It is also called a doc comment.
class Hello { /** Calculation Program. To perform addition of two no. Three varibale is required Program version 1.0 */ public static void main(String args[]) { int a=10,b=20,c; c=a+b; System.out.println("Sum of two no:- "+c); } }
Sum of two no:- 30