摘要: 单例设计模式 保证一个类只有一个实例 懒汉式 (在需要的时候才实例化) 在单线程环境下 实例只有一个 class SingletonTest{ public static void main(String[] args) { Singleton singleton1 = Singleton.getI 阅读全文
posted @ 2020-03-17 17:51 辰梓悦 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 模拟鸭子应用 使用继承 public abstract class Duck { public void quack(){ System.out.println("鸭子呱呱叫"); } public void swim(){ System.out.println("鸭子游泳"); } public 阅读全文
posted @ 2020-03-17 15:31 辰梓悦 阅读(141) 评论(0) 推荐(0) 编辑