zoukankan      html  css  js  c++  java
  • 异常应用场景

    Throwable






    NoSuchElementException 的异常类典型写法,自定义异常类参考!

    public
    class NoSuchElementException extends RuntimeException {
    private static final long serialVersionUID = 6769829250639411880L;

    /**
    * Constructs a <code>NoSuchElementException</code> with <tt>null</tt>
    * as its error message string.
    */
    public NoSuchElementException() {
    super();
    }

    /**
    * Constructs a <code>NoSuchElementException</code>, saving a reference
    * to the error message string <tt>s</tt> for later retrieval by the
    * <tt>getMessage</tt> method.
    *
    * @param s the detail message.
    */
    public NoSuchElementException(String s) {
    super(s);
    }
    }

    Throwable cause 异常类构建

    public class ConcurrentModificationException extends RuntimeException {
    private static final long serialVersionUID = -3666751008965953603L;

    /**
    * Constructs a ConcurrentModificationException with no
    * detail message.
    */
    public ConcurrentModificationException() {
    }

    /**
    * Constructs a {@code ConcurrentModificationException} with the
    * specified detail message.
    *
    * @param message the detail message pertaining to this exception.
    */
    public ConcurrentModificationException(String message) {
    super(message);
    }

    /**
    * Constructs a new exception with the specified cause and a detail
    * message of {@code (cause==null ? null : cause.toString())} (which
    * typically contains the class and detail message of {@code cause}.
    *
    * @param cause the cause (which is saved for later retrieval by the
    * {@link Throwable#getCause()} method). (A {@code null} value is
    * permitted, and indicates that the cause is nonexistent or
    * unknown.)
    * @since 1.7
    */
    public ConcurrentModificationException(Throwable cause) {
    super(cause);
    }

    /**
    * Constructs a new exception with the specified detail message and
    * cause.
    *
    * <p>Note that the detail message associated with <code>cause</code> is
    * <i>not</i> automatically incorporated in this exception's detail
    * message.
    *
    * @param message the detail message (which is saved for later retrieval
    * by the {@link Throwable#getMessage()} method).
    * @param cause the cause (which is saved for later retrieval by the
    * {@link Throwable#getCause()} method). (A {@code null} value
    * is permitted, and indicates that the cause is nonexistent or
    * unknown.)
    * @since 1.7
    */
    public ConcurrentModificationException(String message, Throwable cause) {
    super(message, cause);
    }
    }
  • 相关阅读:
    使用dom4j 解析xml
    xml schema 建立xml文档
    xml dtd 约束建立xml文档
    DBCP 连接池的使用
    c++面向过程和面向对象-C++编译器是如何管理类和对象的
    c++读取文本文件
    一个范围的两个数进行数位的累加,实现对两个数num1和num2的数位和相加
    C++批量注释代码段取消注释代码段快捷键
    利用MATLAB截取一张复杂图片中想要的区域
    python学习之路系列
  • 原文地址:https://www.cnblogs.com/macro-renzhansheng/p/12538157.html
Copyright © 2011-2022 走看看