我該如何擴展Java中的函數? (未類擴展)如何在Java中擴展函數而不是整個類?
/*Example:
* year 1990 Alex Kumar
* year 1990 Jhon Ya'ay
* made this: do not touch modify here */
public static void OldMade()
{
Connect("+1800PIZZA");
Say("MYID:69");
Request("PIZZACITROEN_BLACK");
}
/*Example:
* year 2011 Sunil Williams
* applied which extends 1990 */
public static void MadeInIndia extends this.OldMade
{
//hidden include Connect("+1800PIZZA");
//hidden include Say("MYID:69");
//hidden include Request("PIZZACITROEN_BLACK");
Send("CorrectionPandit");
}
private static void main(Strig args[])
{
// Try 1 call and get old + new
MadeInIndia();
//execute Connect("+1800PIZZA");
//execute Say("MYID:69");
//execute Request("PIZZACITROEN_BLACK");
//execute Send("CorrectionPandit");
}
號可以擴展類並覆蓋只是想「擴展」的單一方法。 – Thilo
這是什麼意思只覆蓋方法,而不是擴展類? –