摘要:
public class SoldierDemo { public static void main(String[] args) { /*Soldier test1=new Army("张三"); test1.action(); Soldier test2=new Navy("李四"); test 阅读全文
posted @ 2016-11-25 16:18
Heavy_dream
阅读(268)
评论(0)
推荐(0)
摘要:
public class Strategy {public static void main(String[] args) {int [] array=new int[]{26,25,15,42,36,16,12};IInfo test1=new BubbleSort(); //接口引用指向实现了此 阅读全文
posted @ 2016-11-25 13:53
Heavy_dream
阅读(183)
评论(0)
推荐(0)
摘要:
public class TemplateMethodDemo { public static void main(String[] args) { Teacher test=new Javatreacher("张三");//动态绑定 test.work(); Teacher test1=new D 阅读全文
posted @ 2016-11-25 11:58
Heavy_dream
阅读(256)
评论(0)
推荐(0)
摘要:
作为对象的创建模式,单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。这个类称为单例类。 单例模式的结构 单例模式的特点: 单例类只能有一个实例。 单例类必须自己创建自己的唯一实例。 单例类必须给所有其他对象提供这一实例。 饿汉式单例类 上面的例子中,在这个类被加载时,静态变 阅读全文
posted @ 2016-11-25 11:55
Heavy_dream
阅读(267)
评论(0)
推荐(0)
摘要:
public class Factory { public static void main(String[] args) {//Client IFruit fruit=Factorytemp.getFruit("香蕉");//这里为什么要使用接口的类型,因为接口的引用可以接收实现此接口的类的实例 阅读全文
posted @ 2016-11-25 11:43
Heavy_dream
阅读(282)
评论(0)
推荐(0)
浙公网安备 33010602011771号