Kotlin Nested try-catch block

We can also able to use nested try block whenever required. Nested try catch block is such block in which one try catch block is implemented into another try block.

The requirement of nested try catch block is arises when a block of code generates an exception and within that block another code statements also generates another exception.

Syntax of nested try block

Kotlin nested try block example

Output:

4 / 2 is 2
Can't divided by Zero!
16 / 4 is 4
32 / 4 is 8
Can't divided by Zero!
128 / 8 is 16
Element not found.





Latest Courses