Java ???????????????????????
???????????? ???????[ 2014/1/13 11:37:27 ] ????????Java ???? ???
?????????????????????JVM???????????
??????? – ???????????????????????
?????????????? – ????????????????????????ж???????????
????Q.????????????“?????????”??????????????????????????????????????????
????A.????????????????????????????ù??????Щ??????????ü?е???????????????????????ж??????????????????ü?е??????????????????????“????”???????????
??????????????????????С???????????????????????????????????й???????????ü?У????“extends”?????????????????????????????е??????????????????????????????????????????
????????????????????С??????????????м?й?????????????????????????????????????????????????????????????????????????????????????????????
????????????????Gang of Four??????????????????????????????е?????????????????????????????????——“???”??“?????????”?????“???????????????????”?????????????????????????????????????????????????????????????????????????????????????????????????
????Q.???????????????????????к????????У???????Java?????????
????A.“???”?????????????????????????????????????????Java?????????????????У????????“extends”????????????????????????????????
public class Parent {
public String saySomething( ) {
return “Parent is called”;
}
}
public class Child extends Parent {
@Override
public String saySomething( ) {
return super.saySomething( ) + “?? Child is called”;
}
}
????“Child”???saySomething()????????????“Parent is called??Child is Called”??????????????ü????????“Parenet is called”???????“super”??????????“Parent”???????????????б???????????????/????????Java??????????????????У??????????????????????“????”????“???”??????????????????????ζ??????????????????????????е???????Java??????????????????£?
public class Parent {
public String saySomething( ) {
return “Parent is called”;
}
}
public class Child {
public String saySomething( ) {
return new Parent( ).saySomething( ) + “?? Child is called”;
}
}
???????????????????á???????????????????????
public class Child {
private Parent parent = null;
public Child( ){
this.parent = new Parent( );
}
public String saySomething( ) {
return this.parent.saySomething( ) + “?? Child is called”;
}
}
??????
???·???
??????????????????
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