???Java??????????
???????????? ???????[ 2013/4/24 9:59:07 ] ????????
?????????????е?????????????InMethod??
????<<interface>> InMethod.java
public interface InMethod {
void public_method();
}
????????????????????????÷????private??????public?????????default??protected??public?????????????public??????
// create a private inner object by 'out's method'??
// but use Interface reference to handle it
InMethod privateIn=out.getPrivateIn();
privateIn.public_method();
????3?????????????????
??????????????н????????DifferPackage.java??
????DifferPackage.java
package com.zj.other;
import com.zj.main.InMethod;
import com.zj.main.Out;
public class DifferPackage {
public static void main(String[] args){
//create an outer object
Out out=new Out();
//create a public inner object by 'new'
Out.PublicIn publicIn=out.new PublicIn();
publicIn.public_arg=0;
publicIn.public_method();
// create a public inner object by 'out's method'
Out.PublicIn publicIn2 = out.getPublicIn();
publicIn2.public_arg=0;
publicIn2.public_method();
//use Interface reference
InMethod method;
method=out.getPrivateIn();
method.public_method();
method=out.getDefaultIn();
method.public_method();
method=out.getProtectedIn();
method.public_method();
method=out.getPublicIn();
method.public_method();
}
}
???????new?????getInnerInstance()??????????public??????public?????public???????????y????????????????????4????????public??????
??????
???·???
??????????????????
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