zoukankan      html  css  js  c++  java
  • 自定义捕获异常

    package com.yunfengtech;

    import java.text.ParseException;

    public class Throw {
    /**
    * 处理激活
    * @throws ParseException
    */
    public void test(int aaa)throws ServiceException{
    int bbb = aaa;
    if(bbb >= 1) {
    if(bbb >= 2) {
    if(bbb >= 3) {
    if(bbb >= 4) {
    throw new ServiceException("0");
    } else {
    throw new ServiceException("4");
    }
    } else {
    throw new ServiceException("3");
    }
    } else {
    throw new ServiceException("2");
    }
    } else {
    throw new ServiceException("1");
    }
    }


    /*public static void main(String args[]) throws ServiceException {
    Throw a = new Throw();
    a.test(4);
    }
    Exception in thread "main" com.yunfengtech.ServiceException: 0
    at com.yunfengtech.Throw.test(Throw.java:16)
    at com.yunfengtech.Throw.main(Throw.java:34)*/
    /*public static void main(String args[]) {
    Throw a = new Throw();
    try {
    a.test(4);
    } catch (ServiceException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    com.yunfengtech.ServiceException: 0
    at com.yunfengtech.Throw.test(Throw.java:16)
    at com.yunfengtech.Throw.main(Throw.java:35)*/

    }

  • 相关阅读:
    实验一
    BZOJ 2564
    P4557 [JSOI2018]战争
    移动自动化-Mac-IOS-appium环境搭建
    Node安装mac版本
    删除N天前文件和空文件
    Python之jsonpath模块
    性能学习
    参数化
    查找测试用例
  • 原文地址:https://www.cnblogs.com/pureEve/p/6405464.html
Copyright © 2011-2022 走看看