Java Throwable.getCause()

Syntax

Throwable.getCause() has the following syntax.

public Throwable getCause()

Example

In the following code shows how to use Throwable.getCause() method.


/*from  w w w . j  av  a 2 s .  c o  m*/
public class Main {
  public static Throwable getDeepestThrowable(Throwable t) {
    Throwable parent = t;
    Throwable child = t.getCause();
    while (null != child) {
      parent = child;
      child = parent.getCause();
    }

    return parent;

  }

}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable