Italian Trulli

Comment In Java and Types of comment in Java

Test Tribe
.
Java Comment With Example

Java Comments
  • Java Comment is Used to hide the selected code.
  • Comments are used to write a detailed description of application logic to understand the logic easily.
  • When we write the comments the application maintenance will become easy.
  • Comments are non-executable code these are ignored during compilation.
  • Java Comment is used to provide the details or explanation of variables, methods, classes or any other statements

Types Of Comments in Java

There are 3 types of java comments.

1) Single-line Comments
2) Multi-line Comments
3)Documentation Comments

1) Single-line Comments
A single-line comment is used to write the description in a single line.

Syntax of Single-line Comments

 //description

Example of a Single line comment 

public class Test
 {  
public static void main(String[] args) 
{  
 int x=40;//Here, xis a variable  
 System.out.println(x);  
}  
}

2) Multi-line Comments
 Java Multi-line Comment is used To write the description in more than one line. Starts /* ends */

Syntax of Multi-line comment 

/* satement-1
Statement-2
;;;;;;;;;;;;;;
Statement-n
*/

Example of multi-line comment 

public class Test
 {  
public static void main(String[] args) 

{  
/*This is an example of
     Multi-line comment*/ 
int x=40;
 System.out.println(x);  
}  
}

3)Documentation Comments
In Java, Documentation Comments are Used to prepare API documents.

Syntax of Documentation Comments

 /*
*statement-1
*statement-2
*/

Example Documentation comment 

/**
*project Name -Test 
* Developer -abc
* Client name -QA acharya
*/
public class Test
 {  
public static void main(String[] args) 

{  
 int x=40;
 System.out.println(x);  
}  
}


Hope The above Tutorial comment in Java is helpful for you...

Team,
QA acharya


Comment In Java With Example

Post a Comment

0 Comments