Selasa, 11 April 2017

How to use throws keyword in java programming

throw Keyword The throw keyword can be used in Java programs to throw exception objects explicitly. The syntax of using throw is as follows: throw ThrowableInstance; The ThrowableInstance can be object of Throwable class or any of its sub classes. A reference to the Throwable instance can be obtained using the parameter in catch block or by using the new operator. Let’s see a sample program that demonstrates the use of throw: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class ArrayException { public static void main(String args) { try { throw new ArithmeticException(“Testing throw”); } catch(Exception e) { System.out.println(e); throw

The post How to use throws keyword in java programming appeared first on Coding Security.


How to use throws keyword in java programming
read more

Tidak ada komentar:

Posting Komentar