Scala Throws Keyword

Scala provides throws keyword to declare exception. You can declare exception with method definition. It provides information to the caller function that this method may throw this exception. It helps to caller function to handle and enclose that code in try-catch block to avoid abnormal termination of program. In scala, you can either use throws keyword or throws annotation to declare exception.

Scala Throws Example

Output:

Exception handeled here
Rest of the code executing...




Contact US

Email:[email protected]

Scala Throws keyword
10/30