public class Ex3{

public class Ex3{
int x;
public static void main(String ar[])throws Exception{
int y=0;
Ex3 c=new Ex3();
try{
y=3/c.x;
y=y+1;}catch(Exception e){
System.out.println("errors occur!");
System.out.println("getMessage="+e.getMessage());
System.out.println("toString="+e.toString());}
System.out.println("program ends ok");
System.out.println("the y is:"+y);
}
}
注释一下每行,不太懂try catch的用法
其他人气:969 ℃时间:2020-05-10 12:45:29
优质解答
public class Ex3{ //类int x; public static void main(String ar[])throws Exception{ //主函数,//throws Exception是遇到异常抛出,如果其他类或函数用到可以用catch捕//捉到int y=0; Ex3 c=new Ex3(); try{ //在t...
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版