Java Method getExceptionTypes() MethodThe 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. SyntaxParameterNo parameter is passed. Returnsexception types declared as being thrown by the executable this object represents ThrowsNo Exception is thrown. Example 1Test it NowOutput: 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 2Test it NowOutput: class java.lang.ArrayIndexOutOfBoundsException
Next TopicJava Method Class
|