package com.wjc.Nio;
/**
* Created by wang.jiancheng on 2017/8/4.
*/
interface InterParent {
public void test1();
public void test2();
}
这是子类,实现了父接口的方法后自己也写了个test方法。
package com.wjc.Nio;
/**
* Created by wang.jiancheng on 2017/8/4.
*/
public class child implements InterParent{
public void test2() {
System.out.println("我是子类重写父类方法的test2----");
}
public void test1() {
System.out.println("我是子类重写父类方法的test1----");
}
public void test() {
System.out.println("我是子类本身的test");
}
public static void main(String[] args) {
InterParent i = new child();
child c = new child();
}
}
随后便可以看到i这个对象只有InterParent的test1方法和test2方法,但是调用的是child的实现。
这是父接口,写了两个test方法。package com.wjc.Nio;/** * Created by wang.jiancheng on 2017/8/4. */interface InterParent { public void test1(); public void test2();}这是子类,实现了父接口的方法后自己也写了个test方法。package