???Java??????????
???????????? ???????[ 2013/4/24 9:59:07 ] ????????
??????Java?У?????????????????????????????????????????????????.this??????????????????????????????????????????г????????private?????
??????????????????????????????????????????????????????????????????????????????????????????????????????????η???????????????????????????????
????????????????????Out.java?????а?????4??????????????????private??default??protected??public???????????????У???????4???????????????????????????Out???????????????????????
????Out.java
package com.zj.main;
public class Out {
public PrivateIn getPrivateIn(){
return new PrivateIn();
}
public DefaultIn getDefaultIn(){
return new DefaultIn();
}
public ProtectedIn getProtectedIn(){
return new ProtectedIn();
}
public PublicIn getPublicIn(){
return new PublicIn();
}
private class PrivateIn implements InMethod{
private int private_arg;
int default_arg;
protected int protected_arg;
public int public_arg;
private void private_method(){};
void default_method(){};
protected void protected_method(){};
public void public_method(){};
}
class DefaultIn implements InMethod{
private int private_arg;
int default_arg;
protected int protected_arg;
public int public_arg;
private void private_method(){};
void default_method(){};
protected void protected_method(){};
public void public_method(){};
}
protected class ProtectedIn implements InMethod{
private int private_arg;
int default_arg;
protected int protected_arg;
public int public_arg;
private void private_method(){};
void default_method(){};
protected void protected_method(){};
public void public_method(){};
}
public class PublicIn implements InMethod{
private int private_arg;
int default_arg;
protected int protected_arg;
public int public_arg;
private void private_method(){};
void default_method(){};
protected void protected_method(){};
public void public_method(){};
}
public static void main(String[] args){
//create an outer object
Out out=new Out();
//create a private inner object by 'new'
Out.PrivateIn privateIn=out.new PrivateIn();
privateIn.private_arg=0;
privateIn.private_method();
// create a private inner object by 'out's method'
Out.PrivateIn privateIn2 = out.getPrivateIn();
privateIn2.private_arg = 0;
privateIn2.private_method();
}
}
???????е?4??????????????????InMethod???y??????????????л??????????????????????????????????????????????????????
??????
???·???
??????????????????
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