package com.zhanzhuang.exception;

public class CustomizeException {
    public static void main(String[] args) {
        judge();
    }

    public static void judge() {
        int a = 2;
        int b = 1;
        if (a > b) {
            try {
                throw new MyException("true");
            } catch (MyException e) {
                e.printStackTrace();
            }
        } else {
            try {
                throw new MyException("false");
            } catch (MyException e) {
                e.printStackTrace();
            }
        }
    }
}

class MyException extends Exception {

    public MyException(String message) {
        super(message);
    }
}

 

posted on 2018-10-30 17:34  帅过驴的袋鼠  阅读(640)  评论(0编辑  收藏  举报