摘要:
代理设计由一个代理主题来操控真实主题,真实主题执行具体的业务操作 interface Network{//定义一个上网接口 public void browse(); } class Real implements Network{4 public void browse(){ System.out 阅读全文
摘要:
工厂模式在接口与子类之间加入一个过渡端,通过此端口实例化对象,一般成这个过渡端为工厂类 interface Fruit{//水果接口 public void eat();//抽象吃方法 } class Orange implements Fruit{//橙子实现水果接口 public void ea 阅读全文
摘要:
多态就是父类引用指向子类对象 例如Animal a = new Dog();//向上转型 多态必须使用向下转型的时候:当在其他类中调用子类对象中独有的方法的时候需要向下转型 Animal a = new Dog(); Dog d = (Dog) a;//向下转型 多态在实际中的应用实际上就是为了程序 阅读全文