java,对于分母为零异常处理

来源:互联网 发布:altair软件 编辑:程序博客网 时间:2024/04/30 18:12


public class xiawu2dian {
 

 public static void main(String[] args) {
  String str=null;
  int strlen=0;
  try
  {
   int a=15/0;
   
  }
  catch(NullPointerException b)//
  {
   System.out.println("异常");
   strlen=3;
   
   
  }
  catch(Exception b)
  {
   System.out.print("捕获exception异常");
   
  }
 System.out.print(strlen);
 }

}

原创粉丝点击