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

原文地址:https://www.cnblogs.com/zyf-yxm/p/13206133.html