Monday, January 5, 2009

Sample of Java Pattern -- Singleton

Utils.java
package singleton;

public class Utils {

private Utils(){}

private static Utils instance = new Utils();

public static Utils getInstance() {
return instance;
}

public void println(String str){
System.out.println(str);
}

public static void main(String[] args) {
Utils.getInstance().println("Hello");
}
}


you may download the source code.

No comments:

Post a Comment