2013年8月7日

命令模式

摘要: package frank;public class App{ public static void main(String[] args) { int[] array = new int[]{0,1,4,5,3,4}; ProcessArray pa = new ProcessArray(); pa.process(array,new PrintCommand());//相同的方法,不同的输出 pa.process(array,new AddCommand());//相同的方法,不同的输出 }}interface Command{ public abstract void proce... 阅读全文

posted @ 2013-08-07 16:20 wp456 阅读(162) 评论(0) 推荐(0)

接口

摘要: package frank;public class App implements Person{ public static void main(String[] args) { App ct = new App(); System.out.println(Person.AGE); } public void get(){};//实现接口,不实现接口的话就只能定义成抽象类。}interface Person extends Person2{ public static final int MAX_SIZE = 10; int AGE = 20; public abstract void .. 阅读全文

posted @ 2013-08-07 10:47 wp456 阅读(212) 评论(0) 推荐(0)

java抽象类

摘要: 关键字:abstract。一个类中有抽象方法或者继承了抽象类或者接口,但是未实现方法,那么这个类必须是抽象类,且不能用final关键字修饰。字段、构造器、类方法不能定义为抽象的。抽象方法不能和private修饰符一起使用。抽象方法不能用static一起使用。局部变量不能定义为抽象的。 阅读全文

posted @ 2013-08-07 10:06 wp456 阅读(122) 评论(0) 推荐(0)

导航