???Java?????Ч????private???η?
???????????? ???????[ 2015/7/9 11:10:14 ] ??????????????????? ???????
??????Java????У????private????????????????????????????????????????????????????????????????????????private?????
??????????????private???η?????????????о????private?????Ч???????
????Java?????
??????Java????????????ù??????Java??????????????漲?????????????????????????????????????????????????????????
????class OuterClass {
????class InnerClass{
????}
????}
???????????Java???????????漰???????????о?????????????????????Java???????????????????
??????????Ч?
????????????????о?????????????????????????????????????private???????????????????????????????????????
????public class OuterClass {
????private String language = "en";
????private String region = "US";
????public class InnerClass {
????public void printOuterClassPrivateFields() {
????String fields = "language=" + language + ";region=" + region;
????System.out.println(fields);
????}
????}
????public static void main(String[] args) {
????OuterClass outer = new OuterClass();
????OuterClass.InnerClass inner = outer.new InnerClass();
????inner.printOuterClassPrivateFields();
????}
????}
??????????????????private???ε??????????????????????????????private????Ч?????
????????????????
???????????javap?????????????????class???
????OuterClass?????????
15:30 $ javap -c OuterClass
Compiled from "OuterClass.java"
public class OuterClass extends java.lang.Object{
public OuterClass();
Code:
0: aload_0
1: invokespecial #11; //Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #13; //String en
7: putfield #15; //Field language:Ljava/lang/String;
10: aload_0
11: ldc #17; //String US
13: putfield #19; //Field region:Ljava/lang/String;
16: return
public static void main(java.lang.String[]);
Code:
0: new #1; //class OuterClass
3: dup
4: invokespecial #27; //Method "<init>":()V
7: astore_1
8: new #28; //class OuterClass$InnerClass
11: dup
12: aload_1
13: dup
14: invokevirtual #30; //Method java/lang/Object.getClass:()Ljava/lang/Class;
17: pop
18: invokespecial #34; //Method OuterClass$InnerClass."<init>":(LOuterClass;)V
21: astore_2
22: aload_2
23: invokevirtual #37; //Method OuterClass$InnerClass.printOuterClassPrivateFields:()V
26: return
static java.lang.String access$0(OuterClass);
Code:
0: aload_0
1: getfield #15; //Field language:Ljava/lang/String;
4: areturn
static java.lang.String access$1(OuterClass);
Code:
0: aload_0
1: getfield #19; //Field region:Ljava/lang/String;
4: areturn
}
??????
???·???
??????????????????
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