java编译报错:No enclosing instance of type test is accessible.
Must qualify the allocation with an enclosing instance of type test (e.g. x.new A() where x is an instance of test).
解决办法实例:
package test;
/**
* @author : suyuyuan
* @date :2016年5月11日 上午10:01:56
* @version 1.0
*/
public class test {
class person
{
private int age;
void shout()
{
this.age=20;
System.out.println("My age is "+age);
}
}
public static void main(String[] args) {
test t=new test();
person p1 = t.new person();
p1.shout();
}
}