public interface OutInterface{//外部接口void interfaceMehtod()}public class outerClass{//外部类privte OutIntrface outInterface = new OutInterfaceImpl();public OutInterface getOutInterface(){// 获取外部接口实现return outInterface ;}private void outMethod(){}private class OutInterfaceImpl implements OutInterface{//内部类实现外部接口void interfaceMehtod(){//外部具体实现利用了外部类的私有方法outMethod()}Baidu,Google地图的Projection
设计技巧9:内部类利用外部类方法实现公共接口 封装实现细节
最新推荐文章于 2022-03-28 01:22:30 发布