zoukankan      html  css  js  c++  java
  • 【Java】No enclosing instance of type XXX is accessible. Must qualify the allocation with an enclosing instance of type XXX(e.g. x.new A() where x is an instance of XXX).的解决办法

    Multiple markers at this line
        - The value of the local variable people is not used
        - No enclosing instance of type TestExtends is accessible. Must qualify the allocation with an enclosing instance of type 
         TestExtends (e.g. x.new A() where x is an instance of TestExtends).

    解决方法:看下是不是把类写在了别的类体里面

    例如

    public class TestExtends {
        public static void main(String[] args) {
            human people = new human();
        }
        
        class human{
            String name;
            
        }
    }

    正确的写法应该是

    public class TestExtends {
        public static void main(String[] args) {
            human people = new human();
        }
    }
    
    class human{
        String name;
        
    }

    这是学面向对象时经常不小心掉的一个坑,特此记录QAQ

  • 相关阅读:
    拖拽组件
    css3动画 巧用label
    轮播图
    弹出框组件,可拖拽
    基于angularJS的分页功能
    身份证验证大全-javascript
    公用拖拽功能插件
    记录那些年我踩过的坑
    节流函数
    手机号码的正则表达式
  • 原文地址:https://www.cnblogs.com/syxy/p/9813174.html
Copyright © 2011-2022 走看看