override 覆盖。在类的继承当中,如果子类想重写父类当中的方法,则为覆盖override。重写的方法名,返回类型,参数皆不变。
例如:
class
parent
... {
public void show()
...{
System.out.println("父类中");
}
}
class son extends parent
... {
public void show()
...{
System.out.println("在子类中");
}
}
public class test
... {
public static void main(String args[])
...{
parent p = new parent();
son s = new son();
p.show();
s.show();
}
}
... {
public void show()
...{
System.out.println("父类中");
}
}
class son extends parent
... {
public void show()
...{
System.out.println("在子类中");
}
}
public class test
... {
public static void main(String args[])
...{
parent p = new parent();
son s = new son();
p.show();
s.show();
}
}
输出结果:
D:/temp>javac test.java
D:/temp>java test
父类中
在子类中
overload 重载。指在同一个类当中,方法签名相同(即方法名相同)的不同方法,每个方法功能不同,仅仅方法签名相同,通过返回类型,参数的不同来实现重载。