多态 对象多态

public class qxy {

	public static void main(String[] args) {
         person p=null;
		student s=new student();
         p=s;
         p.say();
	}

}
public interface  person {
	 int age=18;
    void say(); 
}
 class student implements person {

	@Override
	public void say() {
		System.out.println("锄禾日当午,汗滴禾下土");
		
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_43762083/article/details/119792147