I would like to write troubleshooting code that I can easily remove from later versions of my program debugging. I figured it out:
final static boolean debug_on=true;
...
if (debug_on) { system.out.println() or logger.log(...) }
Is Java smart enough to discard the if statement from the final bytecode if debug == false?
Is there a better practice to achieve the goal of saving debug code from the final version of the program?
source
share