???????Java????????????????????У???????????????裬??Java????????????????????????????????????????????????д?????????????????????????÷??????????????????????????д??????????????????????Java?????????????????????????????????ú????????????????????????????
??????Java?д????????????????????????????????????????????????????????????
??????????
??????????????????????????????????????
???????private??static??final???ε???????????????t?????????鷽???????????????д?????????????????????????ж??????
????????????????????????????????????????????????ɡ?
????????(Overload)???????t????????????д(Override)????????????????ɡ?
????????????????
???????????????????????????
public class TestMain {
public static void main(String[] args) {
String str = new String();
Caller caller = new Caller();
caller.call(str);
}
static class Caller {
public void call(Object obj) {
System.out.println("an Object instance in Caller");
}
public void call(String str) {
System.out.println("a String instance in in Caller");
}
}
}
??????е????
????22:19 $ java TestMain
????a String instance in in Caller
???????????????У?call?????????????????????????????Object?????????????????????????????String?????????????????str?????String???????н???String?????????call?????????á???????????????????????????????е???????
???????
????????????????????????????????javap?????????????????
22:19 $ javap -c TestMain
Compiled from "TestMain.java"
public class TestMain {
public TestMain();
Code:
0: aload_0
1: invokespecial #1                  // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: new           #2                  // class java/lang/String
3: dup
4: invokespecial #3                  // Method java/lang/String."<init>":()V
7: astore_1
8: new           #4                  // class TestMain$Caller
11: dup
12: invokespecial #5                  // Method TestMain$Caller."<init>":()V
15: astore_2
16: aload_2
17: aload_1
18: invokevirtual #6                  // Method TestMain$Caller.call:(Ljava/lang/String;)V
21: return
}