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)
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)
/*
LINES I WANT COMMENTED
LINES I WANT COMMENTED
LINES I WANT COMMENTED
*/
/*
*STUFF HERE
*/
or you can use //
on every line.
Below is what is called a JavaDoc comment which allows you to use certain tags (@return, @param, etc...) for documentation purposes.
/**
*COMMENTED OUT STUFF HERE
*AND HERE
*/
More information on comments and conventions can be found here.
You could use /* begin comment and end it with */
Or you can simply use // across each line (not recommended)
/*
Here is an article you could of read that tells you all about how to comment
on multiple lines too!:
[http://java.sun.com/docs/codeconv/html/CodeConventions.doc4.html][1]
*/
/*
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.
As @kgrad says, /* */ does not nest and can cause errors. A better answer is:
// LINE *of code* I WANT COMMENTED
// LINE *of code* I WANT COMMENTED
// LINE *of code* I WANT COMMENTED
Most IDEs have a single keyboard command for doing/undoing this, so there's really no reason to use the other style any more. For example: in eclipse, select the block of text and hit Ctrl+/
To undo that type of comment, use Ctrl+\
UPDATE: The Sun coding convention says that this should style not be used for block text comments:
// Using the slash-slash
// style of comment as shown
// in this paragraph of non-code text is
// against the coding convention.
but // can be used 3 other ways:
The simple question to your answer is already answered a lot of times:
/*
LINES I WANT COMMENTED
LINES I WANT COMMENTED
LINES I WANT COMMENTED
*/
From your question it sounds like you want to comment out a lot of code?? I would advise to use a repository(git/github) to manage your files instead of commenting out lines.