Monday, July 27, 2009

system.out.println made easy

If you find yourself using too much System.out.println("something") a lot, here is a savior, it got into my head deep down the first time I clamped my eyes on this beast:

public class SomeClass{
private methodName1(params){
doSomething();
log("print whatever on console...");
}
}

public methodName2(params){
log("print waterver2 on console...");
}
}

private static void log(String aMessage){
System.out.println(aMessage);
}
}

---------------
so just using
private static void log(String aMessage){
System.out.println(aMessage);
}

at one place, you can replace all your System.out.println() statements by simply this:

log("some message");

Saves a lot of time and space.

cheers,

~nirmal

No comments:

Post a Comment