死磕java(7)
2015-03-28 22:16 我的梦想那么大 阅读(181) 评论(0) 编辑 收藏 举报http://www.cnblogs.com/liunanjava/p/4296045.html
自己写的例子
package com.sougn.trynew;
public abstract class AbstractTry {
private int id; private String name; public abstract void say(); public void say2() { System.out.print("hello word"); } }
package com.sougn.trynew;
public class AbstractTry2 extends AbstractTry{
public void say() { System.out.print("abstract hello word"); } }
package com.sougn.trynew;
public interface interfacetry {
public void say();
public void sayInterface(); }
package com.sougn.trynew;
public class interfacetry2 implements interfacetry{
public void say() { System.out.print("hello word"); } public void sayInterface() { System.out.print("interfaceTry2"); } }
package com.sougn.trynew;
public interface interfacetry3 extends interfacetry{
public void say3(); }
package com.sougn.trynew;
public class trynew {
public static void main(String[] args) { // TODO Auto-generated method stub AbstractTry2 abstractTry = new AbstractTry2(); abstractTry.say(); abstractTry.say2(); interfacetry2 interfacetry2 = new interfacetry2(); interfacetry2.sayInterface();
}
}