4 ms·
Agreed, checked exceptions surface potential errors to the caller. In that regard Java fares better. However, handling exceptions still require a separate catch
by jrpelkonen 4y ago
Agreed, checked exceptions surface potential errors to the caller. In that regard Java fares better. However, handling exceptions still require a separate catch clause rather than being part of the normal flow. Furthermore, it is nigh impossible to rely on checked exceptions alone, most Java code may throw RuntimeExceptions such as NullPointerException or ArrayIndexOutOfBoundsException and there is no way to know it by just looking at the calling code.
- hota_mazi 4y ago> However, handling exceptions still require a separate catch clause rather than being part of the normal flow Only if you want to catch (handle) it. If you don't want to do that, just declare it in your "throws" clause and enjoy writing your code with the (guaranteed) assumption that you are using a valid value. > Furthermore, it is nigh impossible to rely on checked exceptions alone, most Java code may throw RuntimeExceptions such as NullPointerException or ArrayIndexOutOfBoundsException and there is no way to know it by just looking at the calling code. That's a bug, not a feature. These errors are often unrecoverable, hence why they are runtime and not checked.