try catch语句
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
处理已完成。