覆写(override)就是原来的没有了,被覆盖了;
重载(overload)就是原来的还有,加个新的
重载(overload)就是原来的还有,加个新的
例如:
class A
{
public void f()
{
System.out.println("it is A");
}
}
class A1 extends A
{
public void f()
{
System.out.println("it override A.f()");
}
}
{
public void f()
{
System.out.println("it is A");
}
}
class A1 extends A
{
public void f()
{
System.out.println("it override A.f()");
}
}
这是override
class A2 extends A
{
public void f(int a)
{
System.out.println("it overload A.f()");
}
}
{
public void f(int a)
{
System.out.println("it overload A.f()");
}
}
这是overload