package com.zyl;
public class ArithmeticDemo{
public int devide(int a,int b){
//if(b==0)
//throw new ArithmeticException("b不能为0");
return a/b;
}
public double devide(double a,double b){
// if(b==0)
// throw new ArithmeticException("b不能为0D");
//
return a/b;
}
public static void main(String[] args) {
ArithmeticDemo demo = new ArithmeticDemo();
try {
System.out.println(demo.devide(10D, 0D));
} catch (ArithmeticException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.getMessage());
}
try {
System.out.println(demo.devide(5, 0));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.getMessage());
}
finally{
System.out.println("10/0");
}
System.out.println(demo.devide(45,5));
}