面向对象-简单的基础异常处理 try{}actch(){}


class exceptionDemor //异常处理
{
 int din(int a, int b){
 
 return a/b;
  
   }
}
class  ExceptionDermo
{
 public static void main(String[] args)
 {
  exceptionDemor d = new exceptionDemor();

  try{
    int x = d.din(5,0);
    System.out.println("X="+x);

    }
    catch( Exception e){ //
  
          System.out.println("除0啦!");
    e.printStackTrace();
  
  }
   
   System.out.println("OVR"); 
}
 
}



猜你喜欢

转载自blog.csdn.net/xiexaioyao/article/details/78905894
今日推荐