ݺߣ

ݺߣShare a Scribd company logo
?'???? - ????? ????? ????? - ?????? ??????? - ??????, ????????? ???????
????????? ????????CInner Classes
?????????? ???? ?????????? ????????? ?????? ????? ??????? ???? ???? ????? ?????? ??????? ?????? ????????? ??????? ????? ???????? ???????
??????? ??????? ?????? ?????? ???? ,?????? ????? ???????????private???? ??????? ?????? ?????? .???? ?????????? ???????? ????? ????????
:????? ??????? ??????? ???????? ??????? .???????? ?????
public class OuterClass {
class InnerClass {
}
}
?????? ????????? ???? ???? ????? ,???????? ????????? ????????? ???? ???????? ?????? ?????? ???????? ??????? ???? ?????? ??????? ?????? ????
.???????? ?????? ????? ????????
????:??????? ??????? ???? ???????? ??????? ????
??????????????????? ????? ???? ?????? ?(???? ?????????? ???????? ???? ????????????? ????????? ????????? ????????? ??????? ??"?? ,
:????????????? ???? ??????? ??????? ?????? ????? ?????? ???? ?????????? ,)?????????
public class OuterClass {
public OuterClass() {
InnerClass innerObject1=new InnerClass();
}
class InnerClass {
}
}
????????????????? ?????? ?????? ???? ?(???? ????????? ?????????? ???? ?????? ??????? ?????? ????????? ????????? ????????? ??????? ??"?? ,
:???????? ??????? ????????? ??????? ???????? ????????? ???????? ?????? ???? ???? ,)?????????
public class OuterClass {
public InnerClass getInnerObj() {
return new InnerClass();
}
class InnerClass {
}
}
OuterClass outerObject=new OuterClass(); //In
OuterClass.InnerClass innerObject2=outerObject.getInnerObj(); //Main...
???????????????? ??"?? ,?????????? ????????? ????????? ?????? ?????? ?????? ??????? ????? ?(??? ?????????? ????????? ?????????? ????????
:)?????? ????? ??????????
OuterClass.InnerClass innerObject3=outerObject.new InnerClass(); //In Main...
OR
OuterClass.InnerClass innerObject4=new OuterClass().new InnerClass(); //In Main...
?????????? ????????? ?????????? ???????? ?????? ?????????? ???????? ???? ???? ?????? ????????? ???????? ???? ?????????? ????? ??????
.???????? ???????? ??????? ??????? ??????? ????????? ???????? ???? ???????????
?????? ,???????? ?????? ????????? ??????? ???????? ????? ???????? ?????? ,????????? ???????? ????????????? ??"?? ???????? ???? ??????? ???
???????private,?????? ?????? ???????? ???? ???????? ??????? ????????? ???? ????? ????? ???? ?????????? ???????? ????????? ???? ,
.????? ?????? ????? ???? ????????? ?????? ?????????? ???? ???????? ???? ?????? ?????? ??????? ???????? ?????? ????????? ???????? ???????
?????? ???????? ??????? ???????? ?????????????? ??????? ?????? ????? ??????? ??????? ?????? ???????? ???? ????????? ???????? ????? ,????
??????? ??????? ????? ???? ???? ???????? ???? ???????? ?????? ???????? ???????? ???????? ???????? ,????? ???? ,?????? ???????? ????? ????
final????? ???? ?????? ?????? ???????? ?????? ????????? ???????? ???? ???????? ?????? ?????? ,????? ???? ??????? .?????? ?????????? ??????
????? ????? ?????? ???? ????? ???????? ??????? ??????? ????????? ????? ??????? ????? ,????????? ???????? ???? ????? ???? .????????? ????????
???? ????????? ??????? !?????? ??????? ???????? ????? ?????? ,???????? ????????? ???????? ???? ???????? ???????? ???? ????????
????? ???????? ??????? ????????? ,???????? ??????????????? ???????? ???? ??????? ???????? ???????? ???? ?????? ???? ????????? ???????
!????????
public class OuterClass {
public void defineMethodInnerClass() {
int var=0;
final int finalVar=0;
class methodInnerClass {
public methodInnerClass() {
//System.out.println(var); *ERROR*
System.out.println(finalVar); //*OK*
}
}
}
}
???????? ??????? ???????? ?????? ????????? ???????? ???? ???????? ??????this???? ,??????? ???????? ?????????? ??????? ?????? ??"??
????? ??????? ,?????????? ???????? ?????this??????? ?????? ??"??:?????? ????????? ???? ?????????? ?????????? ????????? ??????????
public class OuterClass {
private int sum=0;
public void setSum(int sum) {
this.sum=sum;
}
class InnerClass {
private int sum=0;
public void incInnerSum() {
this.sum++;
}
public void incOuterSum() {
OuterClass.this.sum++;
}
}
}
,?????? ????????? ???????? ??????? ??????? ,???????? ???????? ???? ??????? ??????? ???????? ????? ?????? ,???????? ???? ????????
???????? ????? ?????? ?????????? ???????? ???? ???????? ????????? ???????? ??????? ???? ,???? ?????? ??????? ?????? ?????? ????????????
(Full Qualified Name.)
.??????? ?????? ???? ?????? ????? ???? ,)??????? ?(?????? ???????? ????????? ????????? ??????? ??????
???? ??????? ????? ??????? ?????? ????????? ????????? ?????? ?????? ?????????? ????????? ?????? ????? ?????? ????? ,???????? ?????? ????????
??? ????????? ?????? ????? ,???????-JVM??? ????? ?????? ????? ,:????????? ??????? ?????? ???????? ??????
?????????? ???????? ??????OuterClass:???? ???????OuterClass.class
????????? ???????? ??????InnerClass:???? ??????? ??????? ?????????OuterClass$InnerClass.class.
??????? ?????? ?????? ???? ???????? ???????-Reflection-.??????? ???????? ???????? ??????
??????????????????? ?????????CAnonymous Inner Classes
????? ,??????? ????? ????????? ?????? ?????? ??????? ,)?(??????????? ?????? ????????? ??????? ???? ?????? ??????? ??????? ???????? ???????
???????? "???????? ?"?????? ??????? ??????? ??????? ??????? "?"??????? ??????? ?????? .????? ???????? ???????? ?????? ??????? ??????? ??????
.??????
???????? ?????? ????? ???????? ?????? ????? ??????? ???????? ???????? ???????? ?????? ??????? ???????? ?????? ,??????? ???????
?"???? ??????? ???????? ??????? ???? ?????? ,????? ???? ,?????? .????? ????? ????? ?????? ??????? ??????? ????? ,?????????? ???????? ????????
??????? ??????? ??????? ??????? ???? ??????? ??????? ??????? "???????.??????
:??????? ?????????? ???????? ??????? ????????? ?????? ???? ??????? ??"??
new Type(/*ARGUMENTS*/) {
/*Methods and Variables that extend/implement class/interface Type*/
};
?????? ???????? ?????? ?????? ?????????? ??????? ??????? ??????? ????? ?????????? ??????? ?????? ???????Type.
???????? ?????????? ?????? ???????? ????????? ????????/??????? ??????? ?????? ???? ??????? ,?????-?????? ???? ????? ?????? ??????? ??????
??????? ??????? ????????? ????? ??????? ??????? ,????? ??????? ??????? ???????? ??????? ??"?? ,?????? ,?????? ??????? ?????? ????? ??????
????????? ????? ???????? ????? ?????? ???? ??????? ????? .???????? ??????? ???????.????????? ?????????? ????????
Type??? ,)??????????? ???????? ???? ???? ?(???? ???????? ??????????? ????????? ????????? ??????????? ???????? ??????? ??????-Type????
.???????? ??????????? ????????? ????????? ??????? ??????? ??????
.?????????? ???????? ??????? ???? ???????? ??????? ??????
?????????? ???? ??????:????????? ????????
public class Human {
public void cout() {
System.out.println("I'm a Human!");
}
}
public class Person extends Human {
public void use() {
Human human1=new Human();
Human human2=new Human(/*No Arguments - Default Constructor @ class Human*/) {
/*Variables that extend class Human*/
int unique=10;
/*Methods that extend class Human*/
public void cout() {
super.cout();
System.out.println("But not just a Human...");
cantAccessDirectly(unique);
}
public void cantAccessDirectly(int u) {
System.out.println("I'm a special kind of Human!");
System.out.println("My Unique ID is: "+u);
}
};
System.out.println("");
System.out.println("cout of human1:");
human1.cout();
System.out.println("");
System.out.println("cout of human2:");
human2.cout();
System.out.println("");
}
}
??? ???????-main???????? ?????????Person???? ?????? ??????? ,use():????? ?????? ???? ???????

cout of human1:
I'm a Human!

cout of human2:
I'm a Human!
But not just a Human...
I'm a special kind of Human!
My Unique ID is: 10

?????????? ??????? ????? ????????? ???? ??????human1???-human2????????? ?????? ???????? ,Human???????? ???????? ???????
???????? ???? ?????? ??????? ???????? ????? ,??????????Human.
???????? ???? ??????? ??????? ??????????? ????????? ????????cout()???? ??????? ??????? ??"?? ????? ,????????? ??????? ???????
Human???? ???????? ?????? ??????? ???? ,cout()?????human1???? ??????? ,cout()????Human??????? ?????? ???? ,???????????
????cout()????human2.??????????? ????????? ???????? ???????? ???? ???? ??????? ,
???????? ????? ,???? ???????cout()????????? ???????? ???????? ???????? ?????? ,???????????????? ,??????????? ????????? ????????
cantAccessDirectly()???????? ?????? ????? ?????? ??????? ?????? ?????? ?????? ????? ??????? ,????? ???? ??????? ,human2???? ????? ,
???????? ???????? ???????? ????????? ?????cout().
??? ?????? ?????????? ????? ???????? ?????? ?????????? ???????? ???????? ??????? ?????? ???????? ,???????????? ??????? ???? ??????
?"??? ?????????-????? ???? ,???????? ???? ????? ????? ????? ??????? ???? ,?????? ???? ?????? ????? ???????? ??????? ??????? ????? ????????? ,"??????
.????? ????? ?????????? ??????? ???????? ?????? ???? ?????? ??????
??????? ?????? ???????? ?????????? ?????? ?????? ???????? ??????? ???????? ????? ???? ?????? ???????? ??????-???( ??????????threads??????? )
??????? ???? ????????? ???????? ???? ????????? ??????? ??????? ??????? ??????? ???????? ?????? ???? ?????? ,?????? :????????
.)???????? ???? ?????? ?????? ?????? ???????? ?????? ?(??????
??? ,?????? ???????? ?????? ???? ??????? ????????? ?????? ?????? ?????? ,???????? ????????? ????? ,"?"????? ???????? ???????????? ?????? ????? ???
??? ??????? ??????? ???? ??????? ???? ??????? ?????? ,?????? ???????? .?????????? ???? ???????? ????????-thread???? ???? ???????? ?????
????? ????? ,???????? ??????? ?????????? ?????? ??????? ?????? ???? ????????? ??????? ????? ??????? ,???? ??????? ,??????? ???????? ????? ?????
??????? ????? ???? ?????? ???????????? ??????...???
??? ??????? ????? ????? ???????? ?????????? ???????? ???????? ??????? ???? ??????? ?????? ,???????????????????? ,???????? ?????????
.??????????? ??????? ?????? ?????? ??????? ??????
???????? ????????? ????????CStatic Nested Classes
.)??????? ???????? ?(??????? ???????? ???????? ??????? ???????? ???????
???? ??????? ?????? ????????? ??????? ,???????? ????????? ????????? ???? ???????? ????? ???? ????????? ??????? ??????? ???????? ????????
.????? ?????????? ??????? ?????? ????? ?????????? ????????? ?????????? ?????? ??????
???????? ???? ????????? ?(??????? ???????? ??????? ???? ????????? ??????? ?????? ?????StaticNestedClass?????????????? ????? )
???????? ???????? ,?????? ??????? ???? ???????main:????? ??????? ,???????? ???????? ??????? ????????? ???????? ???? ,
public class OuterClass {
static class StaticNestedClass {
public void staticNestedMethod() {
}
}
}
??? ?????????? ???????-main:???? ???????
OuterClass.StaticNestedClass staticNestedObject1=new OuterClass.StaticNestedClass();
staticNestedObject1.staticNestedMethod();
??? ???????? ???????? ?????? ,???????-Full Qualified Name???? ??????? ??"?? ,import???????? ??????? ???????? ???????? ????
??? ??????? ??????? ?(??? ????????-main.)
.???????????? ????????? ?????? ???????? ????????? ???????? ????????? ,??????? ??????? ???? ??????? ??????? ?????? ??????? ????
:???? ??????? ??????? ????????? ???????? ???? ??????? ,???? ????
package somepackage;
import staticimport.OuterClass.StaticNestedClass;
,?????? ???????????? ???????? ??????? ?????? ??????:?????????? ??????? ??????? ??????? ???????? ???????
StaticNestedClass staticNestedObject2=new StaticNestedClass();
staticNestedObject2.staticNestedMethod();
???????? ????????? ????? ???????? ???? ???????? ??????? ???? .?????????? ???? ??????? ???? ,??????? ???????? ???????? ??????? ????? ????????
????????? ???????? ?????? ?????? ?????? ??????-private.???????? ????????
??????? ??????? ?????? ????? ???? ????? ??????? ???? ?????? ,???? ???? ??????? ?????? ????????? ???????? ?????? ????? ???????? ??????? ????????
??? ?????? ,???? ????? ,)???? ?(????????? ???????? ???????? ????????? ???????? ??????? ???????? ???? ???????? ???? ??????? ???? ?????????????
??? ?????????? ??????? ????????????.??????????? ??????? ?????? ??????
??????? ????C????? ,??????? ???????? ????????? ?????? ???????? ???????? ???????? ??????? ??????? ??????? ,????????? ????????
.????????? ????? ????? ???? ?????? ??????? ???? ?????? ??????? ????????

More Related Content

?'???? - ????? ????? ????? - ?????? ??????? - ??????, ????????? ???????

  • 2. ????????? ????????CInner Classes ?????????? ???? ?????????? ????????? ?????? ????? ??????? ???? ???? ????? ?????? ??????? ?????? ????????? ??????? ????? ???????? ??????? ??????? ??????? ?????? ?????? ???? ,?????? ????? ???????????private???? ??????? ?????? ?????? .???? ?????????? ???????? ????? ???????? :????? ??????? ??????? ???????? ??????? .???????? ????? public class OuterClass { class InnerClass { } } ?????? ????????? ???? ???? ????? ,???????? ????????? ????????? ???? ???????? ?????? ?????? ???????? ??????? ???? ?????? ??????? ?????? ???? .???????? ?????? ????? ???????? ????:??????? ??????? ???? ???????? ??????? ???? ??????????????????? ????? ???? ?????? ?(???? ?????????? ???????? ???? ????????????? ????????? ????????? ????????? ??????? ??"?? , :????????????? ???? ??????? ??????? ?????? ????? ?????? ???? ?????????? ,)????????? public class OuterClass { public OuterClass() { InnerClass innerObject1=new InnerClass(); } class InnerClass { } } ????????????????? ?????? ?????? ???? ?(???? ????????? ?????????? ???? ?????? ??????? ?????? ????????? ????????? ????????? ??????? ??"?? , :???????? ??????? ????????? ??????? ???????? ????????? ???????? ?????? ???? ???? ,)????????? public class OuterClass { public InnerClass getInnerObj() { return new InnerClass(); } class InnerClass { } } OuterClass outerObject=new OuterClass(); //In OuterClass.InnerClass innerObject2=outerObject.getInnerObj(); //Main... ???????????????? ??"?? ,?????????? ????????? ????????? ?????? ?????? ?????? ??????? ????? ?(??? ?????????? ????????? ?????????? ???????? :)?????? ????? ?????????? OuterClass.InnerClass innerObject3=outerObject.new InnerClass(); //In Main... OR OuterClass.InnerClass innerObject4=new OuterClass().new InnerClass(); //In Main...
  • 3. ?????????? ????????? ?????????? ???????? ?????? ?????????? ???????? ???? ???? ?????? ????????? ???????? ???? ?????????? ????? ?????? .???????? ???????? ??????? ??????? ??????? ????????? ???????? ???? ??????????? ?????? ,???????? ?????? ????????? ??????? ???????? ????? ???????? ?????? ,????????? ???????? ????????????? ??"?? ???????? ???? ??????? ??? ???????private,?????? ?????? ???????? ???? ???????? ??????? ????????? ???? ????? ????? ???? ?????????? ???????? ????????? ???? , .????? ?????? ????? ???? ????????? ?????? ?????????? ???? ???????? ???? ?????? ?????? ??????? ???????? ?????? ????????? ???????? ??????? ?????? ???????? ??????? ???????? ?????????????? ??????? ?????? ????? ??????? ??????? ?????? ???????? ???? ????????? ???????? ????? ,???? ??????? ??????? ????? ???? ???? ???????? ???? ???????? ?????? ???????? ???????? ???????? ???????? ,????? ???? ,?????? ???????? ????? ???? final????? ???? ?????? ?????? ???????? ?????? ????????? ???????? ???? ???????? ?????? ?????? ,????? ???? ??????? .?????? ?????????? ?????? ????? ????? ?????? ???? ????? ???????? ??????? ??????? ????????? ????? ??????? ????? ,????????? ???????? ???? ????? ???? .????????? ???????? ???? ????????? ??????? !?????? ??????? ???????? ????? ?????? ,???????? ????????? ???????? ???? ???????? ???????? ???? ???????? ????? ???????? ??????? ????????? ,???????? ??????????????? ???????? ???? ??????? ???????? ???????? ???? ?????? ???? ????????? ??????? !???????? public class OuterClass { public void defineMethodInnerClass() { int var=0; final int finalVar=0; class methodInnerClass { public methodInnerClass() { //System.out.println(var); *ERROR* System.out.println(finalVar); //*OK* } } } } ???????? ??????? ???????? ?????? ????????? ???????? ???? ???????? ??????this???? ,??????? ???????? ?????????? ??????? ?????? ??"?? ????? ??????? ,?????????? ???????? ?????this??????? ?????? ??"??:?????? ????????? ???? ?????????? ?????????? ????????? ?????????? public class OuterClass { private int sum=0; public void setSum(int sum) { this.sum=sum; } class InnerClass { private int sum=0; public void incInnerSum() { this.sum++; } public void incOuterSum() { OuterClass.this.sum++; } } }
  • 4. ,?????? ????????? ???????? ??????? ??????? ,???????? ???????? ???? ??????? ??????? ???????? ????? ?????? ,???????? ???? ???????? ???????? ????? ?????? ?????????? ???????? ???? ???????? ????????? ???????? ??????? ???? ,???? ?????? ??????? ?????? ?????? ???????????? (Full Qualified Name.) .??????? ?????? ???? ?????? ????? ???? ,)??????? ?(?????? ???????? ????????? ????????? ??????? ?????? ???? ??????? ????? ??????? ?????? ????????? ????????? ?????? ?????? ?????????? ????????? ?????? ????? ?????? ????? ,???????? ?????? ???????? ??? ????????? ?????? ????? ,???????-JVM??? ????? ?????? ????? ,:????????? ??????? ?????? ???????? ?????? ?????????? ???????? ??????OuterClass:???? ???????OuterClass.class ????????? ???????? ??????InnerClass:???? ??????? ??????? ?????????OuterClass$InnerClass.class. ??????? ?????? ?????? ???? ???????? ???????-Reflection-.??????? ???????? ???????? ?????? ??????????????????? ?????????CAnonymous Inner Classes ????? ,??????? ????? ????????? ?????? ?????? ??????? ,)?(??????????? ?????? ????????? ??????? ???? ?????? ??????? ??????? ???????? ??????? ???????? "???????? ?"?????? ??????? ??????? ??????? ??????? "?"??????? ??????? ?????? .????? ???????? ???????? ?????? ??????? ??????? ?????? .?????? ???????? ?????? ????? ???????? ?????? ????? ??????? ???????? ???????? ???????? ?????? ??????? ???????? ?????? ,??????? ??????? ?"???? ??????? ???????? ??????? ???? ?????? ,????? ???? ,?????? .????? ????? ????? ?????? ??????? ??????? ????? ,?????????? ???????? ???????? ??????? ??????? ??????? ??????? ???? ??????? ??????? ??????? "???????.?????? :??????? ?????????? ???????? ??????? ????????? ?????? ???? ??????? ??"?? new Type(/*ARGUMENTS*/) { /*Methods and Variables that extend/implement class/interface Type*/ }; ?????? ???????? ?????? ?????? ?????????? ??????? ??????? ??????? ????? ?????????? ??????? ?????? ???????Type. ???????? ?????????? ?????? ???????? ????????? ????????/??????? ??????? ?????? ???? ??????? ,?????-?????? ???? ????? ?????? ??????? ?????? ??????? ??????? ????????? ????? ??????? ??????? ,????? ??????? ??????? ???????? ??????? ??"?? ,?????? ,?????? ??????? ?????? ????? ?????? ????????? ????? ???????? ????? ?????? ???? ??????? ????? .???????? ??????? ???????.????????? ?????????? ???????? Type??? ,)??????????? ???????? ???? ???? ?(???? ???????? ??????????? ????????? ????????? ??????????? ???????? ??????? ??????-Type???? .???????? ??????????? ????????? ????????? ??????? ??????? ??????
  • 5. .?????????? ???????? ??????? ???? ???????? ??????? ?????? ?????????? ???? ??????:????????? ???????? public class Human { public void cout() { System.out.println("I'm a Human!"); } } public class Person extends Human { public void use() { Human human1=new Human(); Human human2=new Human(/*No Arguments - Default Constructor @ class Human*/) { /*Variables that extend class Human*/ int unique=10; /*Methods that extend class Human*/ public void cout() { super.cout(); System.out.println("But not just a Human..."); cantAccessDirectly(unique); } public void cantAccessDirectly(int u) { System.out.println("I'm a special kind of Human!"); System.out.println("My Unique ID is: "+u); } }; System.out.println(""); System.out.println("cout of human1:"); human1.cout(); System.out.println(""); System.out.println("cout of human2:"); human2.cout(); System.out.println(""); } }
  • 6. ??? ???????-main???????? ?????????Person???? ?????? ??????? ,use():????? ?????? ???? ??????? cout of human1: I'm a Human! cout of human2: I'm a Human! But not just a Human... I'm a special kind of Human! My Unique ID is: 10 ?????????? ??????? ????? ????????? ???? ??????human1???-human2????????? ?????? ???????? ,Human???????? ???????? ??????? ???????? ???? ?????? ??????? ???????? ????? ,??????????Human. ???????? ???? ??????? ??????? ??????????? ????????? ????????cout()???? ??????? ??????? ??"?? ????? ,????????? ??????? ??????? Human???? ???????? ?????? ??????? ???? ,cout()?????human1???? ??????? ,cout()????Human??????? ?????? ???? ,??????????? ????cout()????human2.??????????? ????????? ???????? ???????? ???? ???? ??????? , ???????? ????? ,???? ???????cout()????????? ???????? ???????? ???????? ?????? ,???????????????? ,??????????? ????????? ???????? cantAccessDirectly()???????? ?????? ????? ?????? ??????? ?????? ?????? ?????? ????? ??????? ,????? ???? ??????? ,human2???? ????? , ???????? ???????? ???????? ????????? ?????cout(). ??? ?????? ?????????? ????? ???????? ?????? ?????????? ???????? ???????? ??????? ?????? ???????? ,???????????? ??????? ???? ?????? ?"??? ?????????-????? ???? ,???????? ???? ????? ????? ????? ??????? ???? ,?????? ???? ?????? ????? ???????? ??????? ??????? ????? ????????? ,"?????? .????? ????? ?????????? ??????? ???????? ?????? ???? ?????? ?????? ??????? ?????? ???????? ?????????? ?????? ?????? ???????? ??????? ???????? ????? ???? ?????? ???????? ??????-???( ??????????threads??????? ) ??????? ???? ????????? ???????? ???? ????????? ??????? ??????? ??????? ??????? ???????? ?????? ???? ?????? ,?????? :???????? .)???????? ???? ?????? ?????? ?????? ???????? ?????? ?(?????? ??? ,?????? ???????? ?????? ???? ??????? ????????? ?????? ?????? ?????? ,???????? ????????? ????? ,"?"????? ???????? ???????????? ?????? ????? ??? ??? ??????? ??????? ???? ??????? ???? ??????? ?????? ,?????? ???????? .?????????? ???? ???????? ????????-thread???? ???? ???????? ????? ????? ????? ,???????? ??????? ?????????? ?????? ??????? ?????? ???? ????????? ??????? ????? ??????? ,???? ??????? ,??????? ???????? ????? ????? ??????? ????? ???? ?????? ???????????? ??????...??? ??? ??????? ????? ????? ???????? ?????????? ???????? ???????? ??????? ???? ??????? ?????? ,???????????????????? ,???????? ????????? .??????????? ??????? ?????? ?????? ??????? ??????
  • 7. ???????? ????????? ????????CStatic Nested Classes .)??????? ???????? ?(??????? ???????? ???????? ??????? ???????? ??????? ???? ??????? ?????? ????????? ??????? ,???????? ????????? ????????? ???? ???????? ????? ???? ????????? ??????? ??????? ???????? ???????? .????? ?????????? ??????? ?????? ????? ?????????? ????????? ?????????? ?????? ?????? ???????? ???? ????????? ?(??????? ???????? ??????? ???? ????????? ??????? ?????? ?????StaticNestedClass?????????????? ????? ) ???????? ???????? ,?????? ??????? ???? ???????main:????? ??????? ,???????? ???????? ??????? ????????? ???????? ???? , public class OuterClass { static class StaticNestedClass { public void staticNestedMethod() { } } } ??? ?????????? ???????-main:???? ??????? OuterClass.StaticNestedClass staticNestedObject1=new OuterClass.StaticNestedClass(); staticNestedObject1.staticNestedMethod(); ??? ???????? ???????? ?????? ,???????-Full Qualified Name???? ??????? ??"?? ,import???????? ??????? ???????? ???????? ???? ??? ??????? ??????? ?(??? ????????-main.) .???????????? ????????? ?????? ???????? ????????? ???????? ????????? ,??????? ??????? ???? ??????? ??????? ?????? ??????? ???? :???? ??????? ??????? ????????? ???????? ???? ??????? ,???? ???? package somepackage; import staticimport.OuterClass.StaticNestedClass; ,?????? ???????????? ???????? ??????? ?????? ??????:?????????? ??????? ??????? ??????? ???????? ??????? StaticNestedClass staticNestedObject2=new StaticNestedClass(); staticNestedObject2.staticNestedMethod(); ???????? ????????? ????? ???????? ???? ???????? ??????? ???? .?????????? ???? ??????? ???? ,??????? ???????? ???????? ??????? ????? ???????? ????????? ???????? ?????? ?????? ?????? ??????-private.???????? ???????? ??????? ??????? ?????? ????? ???? ????? ??????? ???? ?????? ,???? ???? ??????? ?????? ????????? ???????? ?????? ????? ???????? ??????? ???????? ??? ?????? ,???? ????? ,)???? ?(????????? ???????? ???????? ????????? ???????? ??????? ???????? ???? ???????? ???? ??????? ???? ????????????? ??? ?????????? ??????? ????????????.??????????? ??????? ?????? ?????? ??????? ????C????? ,??????? ???????? ????????? ?????? ???????? ???????? ???????? ??????? ??????? ??????? ,????????? ???????? .????????? ????? ????? ???? ?????? ??????? ???? ?????? ??????? ????????