dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Beginner
Dec 11, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Eliminate the Need to Comment/Remove Debug Statements


Often, while developing a system, you need to put a lot of debug statements in the code, all which have to be commented/removed before delivering the application. There's a class with a static method that can be used to turn on/off debug statements without having to comment them or remove them. Here it is:
 
class MyDebug{

    private static boolean bDEBUG = true;
    public static void printDebug(String s){

        if(bDEBUG){
            System.out.println(s);
        }
    }

To print a debug statement, a call to MyDebug.printDebug(s) is all that is needed. To turn off debug statements, just change the bDEBUG static variable to false and recompile the application.
Santhosh Ananthakrishnan
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date