接口中没有构造方法,但是可以通过对象的多态性概念,通过接口的子类对其实例化。
/** * Created by xabcd on 2019/2/16. */ interface ja_jiekou { public void fun1(); } class Stu implements ja_jiekou { public void fun1() { System.out.println("Student fun1()"); } }
/** * Created by xabcd on 2019/2/16. */ public class te_jiekou { public static void main(String[] args) { ja_jiekou p = new Stu(); p.fun1(); } } 结果: Student fun1()