I am trying to learn the trick on how to run the code which prints a lot of stuff when the debug flag is on.
How is that done in java.
A very naive way I can think of is have the debug flag in all the methods i write
and write something like
if (this.debug == true){
System.out.println("blah blah");
}
But there should be much more elegant way rather than having all these ifs in code?
Also, is there a way I can get the line number of certain execution in code:
For example if there is an exception
try:
/* line number 22 */
catch Exception e{
//print that exception occured in above line number??
}
Probably very lame questions. THanks