class Test
{ int devide(int x,int y)
{
int reslut=0;
reslut=x/y;
return x/y;
}
}
class TestException
{
public static void main(String [] args)
{
try
{
int reslut=new Test().devide(3,1);
System.out.println(reslut);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.println("programe is running here,that is nomare"); }
}--------------------配置: <默认>--------------------
F:\4\TestException.java:20: incompatible types
found : Exception
required: java.lang.Throwable
catch(Exception e)
^
F:\4\TestException.java:22: cannot resolve symbol
symbol : method getMessage ()
location: class Exception
System.out.println(e.getMessage());
^
2 errors处理已完成。
{ int devide(int x,int y)
{
int reslut=0;
reslut=x/y;
return x/y;
}
}
class TestException
{
public static void main(String [] args)
{
try
{
int reslut=new Test().devide(3,1);
System.out.println(reslut);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.println("programe is running here,that is nomare"); }
}--------------------配置: <默认>--------------------
F:\4\TestException.java:20: incompatible types
found : Exception
required: java.lang.Throwable
catch(Exception e)
^
F:\4\TestException.java:22: cannot resolve symbol
symbol : method getMessage ()
location: class Exception
System.out.println(e.getMessage());
^
2 errors处理已完成。
解决方案 »
- 开发语言互相调用
- 请用移位的方式打印出一个十进制整数的十六进制形式
- 怎么比较MAP里面存的值?值是LIST形式的
- ibatics是什么,能否告诉我下
- 简单问提一个!
- 中秋节送分咯!!!!
- [求助]Java程序UI显示有问题
- Java不借助windows播放.asx后缀名的在线直播
- 请问:在tomcat33/native/mod_jdk/apache1.3/build-unix.sh中 ARCH=i386指的什什么意思?
- 很简单的显示窗口的程序出错 Exception in thread "main" java.lang.NoClassDefFoundError: FirstTest
- 一段代码
- 关于Java IO的小问题
重装下JDK看看
自己写的类,名字最好不要个java.lang包底下的类重名,否则出了错,你都不好查。除非你确实知道自己在做什么。
还是重新安装jdk吧,省事方便
至于编译出错的原因,我已经在我的上一个回复里写了,仔细看看吧。
你怎么试的?你试过在同一个包下另写一个Exception类了?请再试一下。