public class TestSingletone
{ private static TestSingletone t=null; private TestSingletone() { } public static TestSingletone getTestSingletone() { if(t==null) { t=new TestSingletone(); } return t; } } TestSingletone t1 = new TestSingletone.getTestSingletone(); TestSingletone t2 = new TestSingletone.getTestSingletone(); TestSingletone t3 = new TestSingletone.getTestSingletone(); System.out.println(t1==t2); System.out.println(t1==t3);
}