I'm looking for a way to use something similar to #define
in Java. I am aware there's no preprocessor there, but I doubt something like that can't be implemented. Ideally I'm looking for a way to translate this C++ code in Java:
#include <cstdio>
#define HelloWorld
#define BEGIN {
#define END }
#define PROGRAM int main()
#define WRITELN(a) puts(a);
PROGRAM HelloWorld
BEGIN
WRITELN("Hello, World")
END
Before this gets marked as duplicate I want to state that I'm looking for a way for a string constant to be defined before compilation, there are questions on this site about numerical ones, but that's not what I'm looking for. I apparently need to explain again how this question is different. The OP of the question somebody linked is asking whether #define
in Java exists, to which the answer is no. What I'm asking is how do I declare string constants which are evaluated before compilation.
And I'm aware as well that the use for this is limited, but nonetheless I don't see why something along the lines of #define NAME Larry
can't be useful.