static final
fields can be use for conditional compilation.
static final boolean DEBUG = false;
if (DEBUG) {
some code ....
}
some code
will be removed by the compiler.
It is also possible to use the assert
keyword to enable and disable some part of the code. Use java -ea: ..
to control if the code should be enabled or disable. See http://docs.oracle.com/javase/1.5.0/docs/guide/language/assert.html