重载
比如无参构造函数和有参构造函数的重载,方法名一样,其他都可以不一样。
public Admin() {
}
public Admin(int admId, String admUsername, String admPsw) {
this.admId = admId;
this.admUsername = admUsername;
this.admPsw = admPsw;
}
重写
public class Animal {
int age;
int name;
public void eat(){
System.out.println("Eat food.");
}
}
public class Dog extends Animal {
@Override
public void eat() {
System.out.println("Eat bone.");
}
}