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();
    }
    }
    }

  • 相关阅读:
    元组类型
    字符串类型
    列表类型
    python 循环
    python语句
    python运算符
    python1
    软件管理
    rpm yum
    LVM
  • 原文地址:https://www.cnblogs.com/hell/p/5426921.html
Copyright © 2011-2022 走看看