Version: SE 8
User Program Communication
Object Oriented Programming
Searching for: Throw and Catch in Java
Try Catch Block
A try-catch block is used to mitigate errors in code and prevent program crashing during runtime. It 'tries' a block of code that could give an error. If the error (exception) is caught, it will execute a different block of code rather than crash the program.
Declaring an Exception
Apart from the built in exceptions Java provides, exception classes can be written by the programmer. These can then be thrown like the built-in Java exceptions.