在静态方法中实例化非静态类内部类时报错
2016-05-09 22:22
507 查看
在main函数中实例化内部类时会报错:
No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing instance of type Test (e.g. x.new A() where x is an instance of Test).
说没有可用的实例,代码:
No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing instance of type Test (e.g. x.new A() where x is an instance of Test).
说没有可用的实例,代码:
public class Test { public static void main(String[] args){ TimePinter listener = new TimePinter(); Timer timer = new Timer(10000, listener); JOptionPane.showConfirmDialog(null, "Quit program"); <span style="white-space:pre"> </span>System.exit(0); } class TimePinter implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { Date now = new Date(); System.out.println("The current time is "+now); Toolkit.getDefaultToolkit().beep(); } } }
相关文章推荐
- JS获取当前完整的url地址以及参数的方法
- 【题解】2016.5.8SWJTU校赛题解
- HDU 2092 算菜价(结束条件,坑呀!)
- 算法练习6. ZigZag Conversion 把一串字符反N方向n行排列
- 关于HTTP_CLIENT_IP,HTTP_X_FORWAR
- 10大白帽黑客专用的 Linux 操作系统
- 有关Mysql分库分表,读写分离数据库水平拆分
- iOS SDK开发时,有关OC和C++混编造成其它类错误的问题(Compile Sources As Objective-C++)
- 有return的情况下try catch finally的执行顺序
- 折半查找
- 给定数组,创建(带头节点)的单链表(头插法、尾插法)
- SQL SERVER 导入、导出数据到Exce(使用OpenRowset,、OpenDataSource函数)以及访问远程数据库(openrowset/opendatasource/openquery)
- VS2012 安装出错 :通道正在关闭
- poj 3164(最小树形图)
- HDU 1358 (KMP)
- java 内部类
- VS2015 create a C++ console application based on WinRT
- webstrom 中 plugins error 设置里 Languages & Frameworks里面没有JavaScript?
- 学完IT十八掌第1天java基础课程:
- VM和ESXi的一些参数