内部类

public class OutClass
{
    public static int i = 1;
   
    class innerClass
    {
        int i = 5;
    }
   
    class innerClass2
    {
        int i = 6;
    }
}

public class Client
{
   
    /**
     * <一句话功能简述> <功能详细描述>
     *
     * @param args [参数说明]
     *
     * @return void [返回类型说明]
     * @exception throws [违例类型] [违例说明]
     * @see [类、类#方法、类#成员]
     */
    public static void main(String[] args)
        throws Exception
    {
        OutClass oc = new OutClass();
        OutClass.innerClass inner = oc.new innerClass();
        int p = inner.i;
        OutClass.innerClass2 inner2 = oc.new innerClass2();
        int p2 = inner2.i;
        System.out.println("P:" + p + "/******/" + "P2:" + p2);
    }
}

你可能感兴趣的:(内部类)