A static class implementation of Singleton pattern : Singleton Pattern « Design Pattern « Java






A static class implementation of Singleton pattern

A static class implementation of Singleton pattern
/*
The Design Patterns Java Companion

Copyright (C) 1998, by James W. Cooper

IBM Thomas J. Watson Research Center

*/
final class Spooler {
  
  static public void print(String s) {
    System.out.println(s);
  }
}


public class StaticSpool {
  public static void main(String argv[]) {
    Spooler.print("here it is");
  }
}

           
       








Related examples in the same category

1.Singleton Pattern 2Singleton Pattern 2
2.Singleton
3.Singleton pattern in Java 1
4.Singleton pattern in Java 2Singleton pattern in Java 2
5.Singleton pattern in Java 3Singleton pattern in Java 3