Difference between java.lang.RuntimeException and java.lang.Exception
exception, java
Solution
Generally RuntimeExceptions are exceptions that can be prevented programmatically. E.g `NullPointerException`, `ArrayIndexOutOfBoundException`. If you check for `null` before calling any method, `NullPointerException` would never occur. Similarly `ArrayIndexOutOfBoundException` would never occur if you check the index first. `RuntimeException` are not checked by the compiler, so it is clean code.
EDIT : These days people favor `RuntimeException` because the clean code it produces. It is totally a personal choice.
Problem
Someone please explain the difference between `java.lang.RuntimeException` and `java.lang.Exception`? How do I decide which one to extend if I create my own exception?