Kotlin runtime exception, throwable class (Unchecked exception vs Checked exception)
This posting is about the explanation of the exceptions in Kotlin.
1. EXCEPTION
Exception is related to the problem that terminates the program or run the program on the wrong purpose. By knowing and handling the exceptions, we can make the appropriate program.
1) Unchecked Exception
: extends the Runtime Exception Class
User-made mistakes or wrong logic from the developer usually makes this exception.
(1) Arithmetic Exception
when we make arithmetic mistakes or logically impossible calculation, this exception occurs.
For example, when we divide a number by zero, it happens.
(2) Array index out of boud exceptions
When we call the value from undefined index, this exception occurs.
For example, when we assign the data on third space of array, i mean array[2], but the length of the array is 1 or 2, the exception happens.
(3) Security exception
When security violation happens, it occurs.
For example, when we don't have the right of security of something but tries to access it, this exception occurs.
(4) Null pointer exception
When we try to use the null as the existing data.
For example, when we calculate null as an integer number.
2) Checked Exception
: extends the Throwable Class on Compile Time
(1) IOException
This is the exception of the Input or the Output. When we try to make an empty file as an input data.
(2) SQLException
This is the exception of the data. When we try to access the undefined, unenrolled files.
2. Summary
1) checked exception
related to the run time error.
developer can correct it.
2) unchecked exception
terminates the program on the progress of compiling.
can not be detected easily through the human sight.