Skip to content

Instantly share code, notes, and snippets.

@sanpingz
Created May 25, 2012 04:00
Show Gist options
  • Save sanpingz/2785666 to your computer and use it in GitHub Desktop.
Save sanpingz/2785666 to your computer and use it in GitHub Desktop.
单例模式
import static com.mceiba.util.Print.*;
class Sun{
//Singleton
private Sun(){}
private static Sun sun=new Sun();
public static Sun makeSun(){
return sun;
}
}
public class Singleton{
public static void main(String[] args){
//!Sundae sun=new Sundae();
Sun sun=Sun.makeSun();
println("Singleton!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment