java.lang.Throwable.getCause()方法实例
2016-10-11 13:47
423 查看
java.lang.Throwable.getCause()方法实例
由 Neil_ 翻译整理 Windows10用户联盟QQ群:2272705120
<iframe id="iframeu1064372_0" src="http://pos.baidu.com/ockm?rdid=1064372&dc=2&di=u1064372&dri=0&dis=0&dai=1&ps=377x246&dcb=BAIDU_SSP_define&dtm=HTML_POST&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1476164655511&ti=java.lang.Throwable.getCause()%E6%96%B9%E6%B3%95%E5%AE%9E%E4%BE%8B%20-%20java.lang&ari=2&dbv=2&drs=1&pcs=907x692&pss=978x1661&cfv=0&cpl=5&chi=1&cce=true&cec=UTF-8&tlm=1476164655&rw=709<u=http%3A%2F%2Fwww.yiibai.com%2Fjava%2Flang%2Fthrowable_getcause.html<r=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3D3W4yzl3fJ4OtMJTaZ5jb9QBZppYJ8cLphGgJWm_4wXPVK7DzrEcZtY4WRn2lPltjdM6U0DlQ1NBBa1XZM26LuFl2J9hKUaVJcZ_rbTJBITS%26wd%3D%26eqid%3Dc164818e0000a54c0000000557fc7c2c&ecd=1&psr=1920x1080&par=1920x1040&pis=-1x-1&ccd=24&cja=false&cmi=7&col=zh-CN&cdo=-1&tcn=1476164656&qn=1495bcb21fe3c5c6&tt=1476164655492.22.346.353" width="728" height="90" align="center,center" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true" style="box-sizing: border-box; border-width: 0px; border-style: initial; vertical-align: bottom; margin: 0px;"></iframe>
上一篇下一篇
Windows10用户联盟QQ群: 227270512
java.lang.Throwable.getCause() 方法返回此抛出或空的原因,如果原因不存在或未知
声明
以下是java.lang.Throwable.getCause()方法的声明public Throwable getCause()
参数
NA
返回值
此方法返回此抛出或空的原因,如果原因不存在或未知。
异常
NA
例子
下面的例子显示java.lang.Throwable.getCause()方法的使用。package com.yiibai; import java.lang.*; public class ThrowableDemo { public static void main(String[] args) throws Throwable { try { newException(); } catch(Throwable e) { System.err.println(e); // returns null as the cause is nonexistent or unknown. System.err.println("Cause = " + e.getCause()); } } public static void newException() throws Exception { System.out.println("This is newException() function"); throw new Exception("Exception..."); } }
让我们来编译和运行上面的程序,这将产生以下结果:
This is newException() function java.lang.Exception: Exception... Cause = null
相关文章推荐
- java.lang.Package.getAnnotation()方法实例
- java.lang.Class.getResource()方法实例
- java.lang.Package.getPackages()方法实例
- dubbo hessian 的java.lang.Throwable.cause: 'java.net.URISyntaxException' could not be instantiated异常
- Java.lang.Class.getDeclaredMethod()方法用法
- java.lang.reflect.UndeclaredThrowableException原因和解决方法
- java.lang.NullPointerException: Attempt to get length of null array的解决方法
- (转)Java.lang.reflect.Method invoke方法 实例
- java.lang.ProcessBuilder.command(String command)方法实例 代替命令行方式启动程序
- Spring 使用注解注入,调用类实例出现 java.lang.NullPointException 问题的解决方法
- java.lang.System.setProperty()方法实例
- java.util.ResourceBundle.getBundle()方法实例
- Myhabits报错invalid types () or values ()解决方法with invalid types () or values (). Cause: java.lang.NoSu
- java.lang.IllegalStateException:getOutputStream() has already been called for this response的解决方法
- Root cause of ServletException java.lang.OutOfMemoryError解决方法
- java.lang.Object常用方法实例代码
- java.lang.reflect.UndeclaredThrowableException原因和解决方法
- java.lang.Object中getClass()方法的用途
- Java.lang.reflect.Method invoke方法 实例
- java.lang.IllegalStateException: getOutputStream() has already been called for this response解决方法及解释