java接口只能声明对象,但不能实例化对象
interface Person {
public void fun1();}
class Student implements Person {
public void fun1() {
System.out.println("Studnt Class fun1()");
}
}
public class TestInterface {
public static void main(String[] args) {
Person p = new Student();//接口对象实例化,对象的多态性
//如果是Person p = new Person()的话会报错
p.fun1();}
}