zoukankan      html  css  js  c++  java
  • 异常的捕获

    class Maths{
    public int div(String x,String y)throws NumberFormatException,
    ArithmeticException{
    int result=0;
    try{
    int numa=Integer.parseInt(x);
    int numb=Integer.parseInt(y);
    result=numa/numb;
    }catch(Exception e){
    throw e;
    }
    return result;
    }
    }
    public class yicahngbuhuo {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    if(args.length!=2){
    System.out.println("程序运行出错!");
    System.exit(1);
    }
    try{
    Maths mm=new Maths();
    System.out.println(mm.div(args[0],args[1]));
    }catch(Exception e){
    e.printStackTrace();
    }
    }
    }

  • 相关阅读:
    p1373
    考试总结 2018-5-6
    p1044与p1898
    p1905
    p1904 p1903
    p1177
    p1273  日常打表
    p1142
    并查集与并查集模板
    p1265
  • 原文地址:https://www.cnblogs.com/hell/p/5426921.html
Copyright © 2011-2022 走看看