saurabh kumar
saurabh kumar

Reputation: 164

operators as variables name in java same like #define in c

#define AND=&&;
public static final  String  AND = &&; //GIVES ERROR

i want to define the operators as normal variables names in my code same like we do in C language using #define, how do i do that in java ?

Upvotes: 0

Views: 58

Answers (2)

Chris K
Chris K

Reputation: 11927

Java does not come with a preprocessor, however there are some out there such as http://code.google.com/p/pre-processor-java/. It is also possible to use C's preprocessor. However in general it is frowned upon in Java, the creators of Java purposefully left it out of the language.

Upvotes: 1

Bathsheba
Bathsheba

Reputation: 234785

You can't do that in Java.

Java does not have a preprocessor.

Upvotes: 7

Related Questions