Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

unchecked exception in java

/* The only unchecked exception in Java are objects of type RunTimeException
   or any of its descendants. Examples include ArithmeticException, NullPointerException,
   IndexOutOfBoundsException, NumberFormatException, InputMismatchException, etc...
*/

// The method below generates an ArithmeticException, which is an unchecked exception,
// and as such requires no throws clause in its header
public void throwArithmeticException() {
	System.out.println(10/0); // Yields an ArithmeticException
}


 
 
PREVIOUS NEXT
Tagged: #unchecked #exception #java
ADD COMMENT
Topic
Name
3+4 =