Click here to Skip to main content
15,922,427 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.
Posted
Comments
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.

Hi,

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

And then, is just call it:
Java
Utils.print("OK!");

I hope this has helped you

Best regards:
Filipe Marques
 
Share this answer
 
Java has no pre-processing. However, that does not prevent you using a pre-processor of another (for instance C) programming language.
 
Share this answer
 
Comments
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.
—SA
CPallini 10-Nov-13 13:28pm    
Thank you. :-)

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