黑马程序员技术交流社区
标题:
暴力的代码
[打印本页]
作者:
long362144768
时间:
2013-12-5 01:15
标题:
暴力的代码
public class nomain {
static{
System.out.println("hello");
try {
int i = 1/0;
} catch (Exception e) {
System.exit(0);
}finally{
System.out.println("world");
}
}
}
复制代码
看看能打印出什么?
作者:
汪洋大海
时间:
2013-12-5 06:11
错误: 在类 nomain 中找不到主方法, 请将主方法定义为:
public static void main(String[] args)
话说同学,你是在美国吗?半夜来发帖。
作者:
kongling
时间:
2013-12-5 09:18
打印"hello"
如果,调用System.exit()方法后,即使是fianlly{},里的代码也不会再执行,直接退出虚拟机。
作者:
珊湖礁
时间:
2013-12-5 10:51
打印hello,后面的的world不会显示
作者:
王家胜
时间:
2013-12-5 14:23
本帖最后由 王家胜 于 2013-12-5 14:24 编辑
没有入口函数是启动不了的
错误: 找不到或无法加载主类 main
你要表达的意思的程序是
import java.io.File;
public class nomain {
static{
System.out.println("hello");
try {
int i = 1/0;
} catch (Exception e) {
System.exit(0);
}finally{
System.out.println("world");
}
}
public static void main(String[] args) {
}
}
复制代码
作者:
chick2018
时间:
2013-12-5 14:27
实际上是编译错误
作者:
简★零度
时间:
2013-12-5 23:03
下次问题解决了就把类型改成提问结束!谢谢!
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2