?????????????е?????????????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??????