No enclosing instance of type VolatleTest is accessible. Must qualify the allocation with an enclosing instance of type VolatleTest

语法错误:No enclosing instance of type VolatleTest is accessible. Must qualify the allocation with an enclosing instance of type VolatleTest (e.g. x.new A() where x is an instance of VolatleTest).
例:

    public static void main(String[] args) {
        Task1 t1 =new Task1();//这里实例化的时候会报错,需要用 static 关键字来修饰内部类
    }
    
    class Task1 implements Runnable{

        @Override
        public void run() {
            
        }
        
    }

解决: static class Task implements Runnable

No enclosing instance of type VolatleTest is accessible. Must qualify the allocation with an enclosing instance of type VolatleTest

上一篇:SQL Server 部分数据库问题。 sp_configure 值 'contained database authentication' 必须设置为 1 才能 创建 包含的数据库


下一篇:php 安装扩展