本文主要是介绍No enclosing instance of type test is accessible.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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();
}
}
这篇关于No enclosing instance of type test is accessible.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!