Java?????????????
???????????? ???????[ 2016/7/21 10:17:50 ] ??????????????????? Java
?????????????????????????????????????????????????????????????????Java???????????????????????С???Щ????????????????????????????????????????????????????????????????????????????????У??????????????????????.?????????????????????????У???????????????????????????????????????????????????????????????????????????????????????????????Java?????????????????????????????????????????????????У??????????
??????? ???
??????????????????????????????????????????????????????У????????????????????????????????????????檔
????????????????????????????????????????????????????????????κξ??????????????????κ?????????洢?????????????????????????
interface CanFight {
void fight();
}
interface CanSwim {
void swim();
}
interface CanFly {
void fly();
}
public class ActionCharacter {
public void fight(){
}
}
public class Hero extends ActionCharacter implements CanFight??CanFly??CanSwim{
public void fly() {
}
public void swim() {
}
/**
* ????fight()????????и????????????????????
*/
}
?????????????
??????????y???????????????????к????????????????????????????????????е??????????????????????????????????????????????????????????????????????????????????????????????У??????????????????????????????????и????????????????
?????????????Father?????Mother??
public class Father {
public int strong(){
return 9;
}
}
public class Mother {
public int kind(){
return 8;
}
}
????????????????????Son??
public class Son {
/**
* ???????Father??
*/
class Father_1 extends Father{
public int strong(){
return super.strong() + 1;
}
}
class Mother_1 extends Mother{
public int kind(){
return super.kind() - 2;
}
}
public int getStrong(){
return new Father_1().strong();
}
public int getKind(){
return new Mother_1().kind();
}
}
???????????
public class Test1 {
public static void main(String[] args) {
Son son = new Son();
System.out.println("Son ??Strong??" + son.getStrong());
System.out.println("Son ??kind??" + son.getKind());
}
}
----------------------------------------
Output:
Son ??Strong??10
Son ??kind??6
????????????????????????????????????????????????????????????????????????????????????и???Father???????Mother????????????????????????????????????????????????????????????????????????????????????????????????????????????????в?????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11