码迷,mamicode.com
首页 > 其他好文 > 详细

异常类Exception(String message, Throwable cause)中的cause理解

时间:2017-10-09 15:23:48      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:hat   exception   ica   cat   except   理解   有一个   throwable   等于   

  这个在构造函数里面竟然有一个Throwable,感觉有些奇怪。

1.

  Throwable cause 这里cause要传一个Throwable的子类异常进去么?

  是引起这个异常的异常,如果这个值是空值,那么这个异常就是源头;如果这个值等于自己,那么这个异常还没被初始化。

  /**
* The throwable that caused this throwable to get thrown, or null if this
* throwable was not caused by another throwable, or if the causative
* throwable is unknown. If this field is equal to this throwable itself,
* it indicates that the cause of this throwable has not yet been
* initialized.
*
* @serial
* @since 1.4
*/

异常类Exception(String message, Throwable cause)中的cause理解

标签:hat   exception   ica   cat   except   理解   有一个   throwable   等于   

原文地址:http://www.cnblogs.com/juncaoit/p/7641050.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!