In C++ if we do not want some statements to compile into code that ships like assert function calls, we control their compilation through #ifndef preprocessor directives.

How do we do this in Java?

I have some System.out.println() statements for debugging which I would like to remove for the final code.

one way is to make them execute conditionally under the affect of a boolean variable. Is there a better way of doing this?

As I have a java swing application I can turn off the System.out.println statements without affecting the output. What is the method of doing this?