Javatpoint Logo
Javatpoint Logo

Java Throwable getMessage() method

The getMessage() method of Java Throwable class is used to get a detailed message of the Throwable.

Syntax

Return

It returns a detailed message string of the Throwable instance (which may be NULL).

Example 1

Test it Now

Output:

/ by zero

Example 2

Test it Now

Output:

For input string: "Java"
java.lang.NumberFormatException: For input string: "Java"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at ThrowableGetMessageExample2.main(ThrowableGetMessageExample2.java:5)
Next TopicJava Throwable



Help Others, Please Share

facebook twitter pinterest