- Overloading (多載) --> over(超過) loading(負載)
- Overriding (覆載) --> over(超過) riding(騎)
public class Person {
public wear(Clothe clothe) {...} // 穿衣服
public wear(Pant pant) {...} // 穿褲子
public wear(Shoe shoe) {...} // 穿鞋子
}
public wear(Clothe clothe) {...} // 穿衣服
public wear(Pant pant) {...} // 穿褲子
public wear(Shoe shoe) {...} // 穿鞋子
}
public class Parent {
public wear(Clothe clothe) {...} //父親穿的衣服
}
public wear(Clothe clothe) {...} //父親穿的衣服
}
public class Child extends Parent {
@override
public wear(Cloth clothe) {...}//兒子穿的衣服
}
@override
public wear(Cloth clothe) {...}//兒子穿的衣服
}
沒有留言:
張貼留言