import java.util.*;
class Out
{
class In
{
public In()
{
System.out.println("非静态内部类构造器");
}
}
}
public class CreatInnerInstance
{
public static void main(String[] args)
{
Out.In in = new Out().new In();
/*
以上的代码可分开写为:
Out.In in;
Out out = new Out();
in = out.new In();
*/
}
}
class SubClass extends Out.In
{
//显示定义SubClass的构造器
public SubClass(Out out)
{
//通过转入的Out对象显示调用In的构造器
out.super();
}
}
|
|