- package com.itheima.net;
- public class Game9
- {
- public static void main(String[] args)
- {
- new Temp().method();
- }
- }
- class Temp
- {
- private class In
- {
- // ---
- int a = 11;
- int b = 22;
- In()
- {
- System.out.println("我是In类的构造函数");
- }
- void methodIn()
- {
- System.out.println("我是In类的method");
- }
- }
- Temp()
- {
- // ---
- System.out.println("我是Temp的构造函数");
- }
- public void method()
- {
- // ---
- In in = new In();
- in.methodIn();
- System.out.println("我是Temp的method");
- }
- }
复制代码
可以用啊. 内部类成了外部类的成员, 当然可以使用private修饰的成员 |