keyword in java which is similar to define in C [duplicate]

You need to use a method in a helper class.

e.g.

enum Helper {;

    static void p(String fmt, String... args) { System.out.printf(fmt, args); }
    static void p(Number n) { System.out.print(n); }
}

so you can call

import static mypackage.Helper.p;

p("hello world");

There is no scanf though you can use a Scanner to do something similar.

Most of the useful things you can do with macros, you can do with simple Java syntax. In term the JIT will optimise the code at runtime to get the same performance benefits.

Leave a Comment