Java Comments

Java supports 3 type of comments

1. Single Line Comments

any line starting with // (double Front Slash)

package C1;

public class Animal {
	String animalName;                 
        //String age ;                         // It is single line comments

	public void setAnimalName(String name) {      
		animalName = name;
	}

}

2. Multi Line Comments

package C1;

public class Animal {
	String animalName;                 
        /* String age ;   
           String owner ;
           */                       

	public void setAnimalName(String name) {      
		animalName = name;
	}

}

Few Other Examples of Multi Line Comments

/* int x =10 
   // int y ;
*/



/* int x = 10
     /* int y  ;
*/

3. Document Comments

/**
* Javadoc multiple-line comment
* @author Neeraj Baliyan
*/

For Your kind attention Please –

If you are preparing for Java Certificate exam, You can take a Practice Test by clicking here. Practice Test have real exam questions. Thus it will ensure that you pass your Certificate Exam without any surprise.

  If you want to crack an interview for the Java Developer role, a demo interview will fortify your chances. Thus, Book an interview preparation session.

Workspace in use - Eclipse Error

Leave a Comment

आपका ईमेल पता प्रकाशित नहीं किया जाएगा.

Shopping Cart