Is there an equivalent to #IF and # CONST.NET in Java / Android?

I have a project in which there are many codes available only in a certain version, and when I fix the error, I have to fix them in all copies. It is very uncomfortable.

Is there in Java #IFand #CONST, what if the sentence #IFis false, the code will not be compiled?

+5
source share
2 answers

There is no “official” pre-processor for Java, and there is no third-party one that is widely used.

- , , , IDE .

, , Java. ( , ) .

, , :

 static final DEBUG = false;

 public void frobnicate() {
   if (DEBUG) {
     doExpensiveFrobnicationDebugOperation();
   }
   doActualFrobnication();
 }

, - .class.

+6

, Java, , , .

0

All Articles