Javatpoint Logo
Javatpoint Logo

Java Method getExceptionTypes() Method

The getExceptionTypes ()method of Method class returns an array of type Class objects that represent the types of the exceptions declared to be thrown by the executable represented by this object. An array of length 0 is returned if the executable declares no exceptions in its throws clause.

Syntax

Parameter

No parameter is passed.

Returns

exception types declared as being thrown by the executable this object represents

Throws

No Exception is thrown.

Example 1

Test it Now

Output:

Exception Thrown by Method: getValue
Exception Array length: 0
Exception Thrown by Method: setValue
Exception Array length: 3
java.lang.ClassNotFoundException    //exception
java.lang.ArrayIndexOutOfBoundsException  
java.lang.ArithmeticException

Example 2

Test it Now

Output:

class java.lang.ArrayIndexOutOfBoundsException 
Next TopicJava Method Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA