No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing
2018-01-12 17:36
447 查看
No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing instance of type SmsUtils (e.g. x.new A() where x is an instance of SmsUtils).
今天在写一个短信发送的工具类时使用到了内部类,在实例化内部类时遇到此错误。SmsResult result = new SmsResult();没有可以访问SmsUtils类型的封闭实例。必须使用封闭的SmsUtils类型的实例来限定分配(例如,x.new A(),其中x是SmsUtils的一个实例)。
SmsResult 是一个(非静态的)内部类。 正在从静态上下文创建它。您需要提供一个Server实例作为外部实例。但是,几乎可以肯定我想让 SmsResult 成为一个静态的嵌套类,或者可能是一个外部类。
刚好今天看到一篇文章中提到: 今天面试我问你static关键字有哪些作用,如果你答出static修饰变量、修饰方法我会认为你合格,答出静态块,我会认为你不错,答出静态内部类我会认为你很好,答出静态导包我会对你很满意,因为能看出你非常热衷研究技术。
给 SmsResult 类的定义添加 static 关键字就ok了。
今天在写一个短信发送的工具类时使用到了内部类,在实例化内部类时遇到此错误。SmsResult result = new SmsResult();没有可以访问SmsUtils类型的封闭实例。必须使用封闭的SmsUtils类型的实例来限定分配(例如,x.new A(),其中x是SmsUtils的一个实例)。
SmsResult 是一个(非静态的)内部类。 正在从静态上下文创建它。您需要提供一个Server实例作为外部实例。但是,几乎可以肯定我想让 SmsResult 成为一个静态的嵌套类,或者可能是一个外部类。
刚好今天看到一篇文章中提到: 今天面试我问你static关键字有哪些作用,如果你答出static修饰变量、修饰方法我会认为你合格,答出静态块,我会认为你不错,答出静态内部类我会认为你很好,答出静态导包我会对你很满意,因为能看出你非常热衷研究技术。
给 SmsResult 类的定义添加 static 关键字就ok了。
相关文章推荐
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- java编译错误No enclosing instance of type TestFrame is accessible. Must qualify the allocation with an enclosing instance of type TestFrame (e.g. x.new A(
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- 【转】Java中No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- <java>No enclosing instance of type GraphicFrame is accessible. Must qualify the allocation with an
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type Monster is accessible. Must qualify the allocation with an enclosing i
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instance of type E(e.g. x.new A() where x is an
- <java>No enclosing instance of type GraphicFrame is accessible. Must qualify the allocation with an
- No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing inst
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type TextRunnable is accessible. Must qualify the allocation with an enclos
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing 问题解释
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing