标签:end 继承 blog turn ges new ima .com image
package day16;
class A{
int f(int x,int y){
return x+y;
}
}
class B extends A{//B继承A并重写A 中的方法
double f(double x,double y){
return x*y;
}
}
public class AnonymityClassTestR {
public static void main(String[] args) {
B b=new B();
A a = new A();
System.out.println(a.f(4, 5));
System.out.println(b.f(4,5));
System.out.println(b.f(4.0, 5.0));
}
}
输出的结果:
标签:end 继承 blog turn ges new ima .com image
原文地址:http://www.cnblogs.com/bigswallow/p/7545087.html