Java: Is there support for macros?

Legend picture Legend · Nov 13, 2009 · Viewed 12.5k times · Source

I am just curious on how people solve this. I often write the same type of code all the time. For instance:

new Thread() {
   //...
   //...
   //...
   //Change this line
   //...
   //...
}.start();

I keep changing the line where it says "Change this line" and then starting a thread. This change can be one line or a few lines. How would I go about compacting this code?

Answer

gnud picture gnud · Nov 13, 2009

Well, I guess you could run your java files through the C preprocessor...