Learn Java Programming - Exceptions: Throws Keyword Tutorial

preview_player
Показать описание
The throws keyword is used to create a list of checked exceptions that are not handled in the code block of either a method or a constructor. A method or constructor does not need to specify any unhandled unchecked exceptions in the throws list.
The throws list must be after the method or constructor signature and before the opening curly brace of the code block:
( return type ) ( methodName(parameter list) )( throws ) ( ExceptionClass ) { method body }

Java exception handling has a principle called the catch or specify requirement that applies to checked exceptions. A method or constructor body that invokes a method or a constructor that throws a checked exception must either handle that exception with a try/catch statement, or specify that checked exception in the throws list.
Рекомендации по теме
Комментарии
Автор

Nice... but it would be easier to see on a proper editor to see where the errors are.. idk.. but very nice <3

amulyabikumandla
Автор

The exception on the main class did not there to nothing, it was passed up to the command process and ended execution with an exit code

ChrisAthanas