No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing
来源:互联网 发布:家庭防火知多少作文 编辑:程序博客网 时间:2024/05/17 23:25
今天准备写一个串口通信的Java类,其中有个内部类,用来执行读写操作,但是在main方法中声明内部类的时候有错误提示:
No enclosing instance of type SPComm is accessible. Must qualify the allocation with an enclosing instance of type SPComm(e.g. x.new A() where x is an instance of SPComm)
public static void main(String[] args){init();CommThread commThread = new CommThread();//错误提示}问题就出在CommThread这个内部类,它不是static的:
private class CommThread extends Thread{private final InputStream commInputStream;private final OutputStream commOutputStream;public CommThread(){commInputStream = inputStream;commOutputStream = outputStream;}父类的static方法不能调用非static的成员,所以修改的方法是把CommThread类修改为static的:
private static class CommThread extends Thread...
0 0
- No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instanc
- - No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing in
- No enclosing instance of type Monster is accessible. Must qualify the allocation with an enclosing i
- No enclosing instance of type ChuangKou is accessible. Must qualify the allocation with an enclosing
- 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 E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing inst
- No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing ins
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing insta
- 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 instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type * is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type test is accessible. Must qualify the allocation with an enclosing inst
- virsh console 无法连接到虚拟机
- Java 8新特性:lambda表达式(四)转载总结
- SSL证书
- 垃圾收集器:引用计数算法
- 将若干个字符串按字母顺序(由小到大)输出。(指针数组)
- No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing
- FileZilla 425 Can't open data connection
- JDK 安装以及环境变量的配置(Windows)
- C++第一次复习笔记
- 在mini2440上移植Boa服务器
- RenderMonkey学习之熟悉软件
- 计蒜客 第19题:加一
- IOS:通知与消息机制
- eclipse如何导入三方jar包