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


  这个在构造函数里面竟然有一个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
*/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM