There is no preprocessor in Java. Depending on your build system, you may be able to use a third-party preprocessor (you can find lots of them by searching for "java preprocessor"). Some examples are
Depending on the scope you want to comment out, you can use block comments and sometimes something like
if (false) {
. . .
}
If all else fails, just comment out every line using //
. Most IDEs have a way to do this (and undo it) efficiently.
P.S. If you can use block comments (not always possible, since block comments can't be nested in Java), there's a nice trick that makes it easier to toggle off and on the comment-out portion. Start your block comment on a line by itself, but end it with another isolated line that starts with a line comment, like this:
/*
<block of code ignored as comment>
//*/
Then if you want to turn the commented-out section back on, just add a second /
at the start of the block:
//*
<block of code now active>
//*/
To toggle the code off again, just remove the first /
. (Without the //
at the start of the last line, the dangling */
would be a syntax error whenever you activated the code by adding a /
to the opening line of the block.)