Latest News

 










Null Object Example (2/2)

Previous slide Next slide Back to first slide View graphic version


Null Object Example (2/2)


 
My other sites

Latest News

 










Null Object Example (2/2)

    class NullLogger implements Logger {


    public void log(String msg) {

    //log nothing

    }

    }

    public class Example {

    static Logger myLogger;

    public static void main(String argv[]) {

    myLogger = new FileLogger();

    myLogger.log("Application Started");

    myLogger = new NullLogger();

    myLogger.log("Application about to terminate");

    }

    }

Previous slide Next slide Back to first slide View graphic version