静态内部类实现单例
调用 TestUtil.getInstance().logTest();
public class TestUtil {
private TestUtil(){
}
private static class TestUtilHolder{
private static TestUtil testUtilInstance = new TestUtil();
}
public static TestUtil getInstance(){
return TestUtilHolder.testUtilInstance;
}
public void logTest(){
Log.i("test","静态内部类实现单例模式");
}
}