- The
tryblock will execute a sensitive code which can throw exceptions - The
catchblock will be used whenever an exception (of the type caught) is thrown in the try block - The
finallyblock is called in every case after the try/catch blocks. Even if the exception isn’t caught or if your previous blocks break the execution flow. - The
throwkeyword will allow you to throw an exception (which will break the execution flow and can be caught in acatchblock). - The
throwskeyword in the method prototype is used to specify that your method might throw exceptions of the specified type. It’s useful when you have checked exception (exception that you have to handle) that you don’t want to catch in your current method.
Resources :
- oracle.com – Lesson: Exceptions
On another note, you should really accept some answers. If anyone encounter the same problems as you and find your questions, he/she will be happy to directly see the right answer to the question.