// Importing the ArithmeticException class
import kotlin.ArithmeticException
fun main(args : Array<String>){
var x = 10
var y = 3
try{
println("10/3: " + x/y)
x = 10
y = 0
println("10/0: " + x/y)
}
catch(e: ArithmeticException){
// caught and handles it
println("Divide by zero exception")
}
}
Example:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer