Gilad
Gilad

Reputation: 841

Not compiling parts of the code in java(like #ifdef)

I want to have the possibility NOT to compile parts of my JAVA code. Sometimes...

I miss the possibility of compiler directives I had in c++

#ifdef DEBUG
 println("debug messae);
#endif

In java we don't have this possibility.

I wondered if there is an external tool, some sort of a Java precompiler that might give me the flexibility to do this with java code.

Thank you, Gilad

Upvotes: -1

Views: 97

Answers (1)

stinepike
stinepike

Reputation: 54722

static final booleans can be used to eliminate code inside if statements at compile time. for example

private static final boolean check= false;    

if (check) {
  // This is removed at compile time
}

Upvotes: 0

Related Questions