Created
May 25, 2012 04:00
-
-
Save sanpingz/2785666 to your computer and use it in GitHub Desktop.
单例模式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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