Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Java what is the syntax for commenting out multiple lines?

Tags:

java

comments

In Java what is the syntax for commenting out multiple lines?

I want to do something like:

(comment)
LINES I WANT COMMENTED
LINES I WANT COMMENTED
LINES I WANT COMMENTED
(/comment)
like image 409
David Avatar asked Mar 15 '10 17:03

David


People also ask

What is the syntax for a multi line comment?

/* */ (multiline comment)

What are the syntax for a comment in Java?

By convention, in Java, documentation comments are set inside the comment delimiters /** ... */ with one comment per class, interface, or member. The comment should appear right before the declaration of the class, interface or member and each line of the comment should begin with a "*".

What is /* in Java?

/** and /* in Java comments All characters available inside any comment are ignored by Java compiler. /** is known as documentation comments. It is used by Javadoc tool while creating the documentation for the program code. /* is used for multi-line comments.


2 Answers

/* 
LINES I WANT COMMENTED 
LINES I WANT COMMENTED 
LINES I WANT COMMENTED 
*/
like image 180
Andrey Avatar answered Oct 01 '22 04:10

Andrey


/* 
Lines to be commented
*/

NB: multiline comments like this DO NOT NEST. This can be the source of errors. It is generally better to just comment every line with //. Most IDEs allow you to do this quite simply.

like image 21
kgrad Avatar answered Oct 01 '22 03:10

kgrad