main方法访问普通内部类的例子:
//外部类test
public class Test {
//非静态的外部类成员变量int num=1;
/*** 普通内部类Person**/class Person{int age;}public static void main(String[] args) {/*** mian()调用一般内部类*/
//创建外部类Test对象Test a=newTest();
//使用外部类对象a来new一个person对象mmPerson mm=a.new Person();System.out.PRintln(mm.age=100);
//静态内部类不能直接访问外部类的非静态成员,但可以通过 new 外部类().成员 的方式访问 System.out.println(new Test().num);}}
新闻热点
疑难解答