How to use try catch exception handling in Groovy

1 Answer

0 votes
try {
        def arr = new int[5]
        arr[12] = 848
} catch(Exception ex) {
        println "Exception: ${ex}"
}
		
println "After try catch"



/*
run:

Exception: java.lang.ArrayIndexOutOfBoundsException: Index 12 out of bounds for length 5
After try catch

*/

 



answered Oct 6, 2020 by avibootz

Related questions

1 answer 419 views
1 answer 199 views
1 answer 212 views
...