Javatpoint Logo
Javatpoint Logo

Kotlin throw keyword

Kotlin throw keyword is used to throw an explicit exception. It is used to throw a custom exception.

To throw an exception object we will use the throw-expression.

Syntax of throw keyword

Kotlin throw example

Let's see an example of throw keyword in which we are validating age limit for driving license.


Exception in thread "main" java.lang.ArithmeticException: under age

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA