Click here to Skip to main content
15,072,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is there any substitution macro (like #define) available in java similar to c?
is precompilation exist in java?
bcz i have home work of writing the java programs where i have to use System.out.println() function nearly 1000 times.if there exist any substitution macro i can replace System.out.println
as sop.
Richard MacCutchan 11-Nov-13 12:50pm
i have to use System.out.println() function nearly 1000 times
I suspect that your design needs to be reviewed.

Java has no pre-processing. However, that does not prevent you using a pre-processor of another (for instance C) programming language.
Sergey Alexandrovich Kryukov 10-Nov-13 13:12pm
Not that the pre-processor itself is evil, but the habit to use it can be :-). My 5.
CPallini 10-Nov-13 13:28pm
Thank you. :-)

You can use, to achieve the macro behavior, a static method.
public class Utils {
   public static void print(String text) {
      // Stuff...
      // More stuff...

And then, is just call it:

I hope this has helped you

Best regards:
Filipe Marques

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900