Why is the runtime exception “unchecked” in Java?
•
Java
Why are runtime exceptions unchecked meaningful (not if they are checked)?
Solution
If you do not, you must use the try / catch block every time you access array elements, perform division operations, and many other common schemes
In other words, imagine this Code:
Map map = ... int i = ... (int[])map.get("foo")[3] = 2334 / i;
I must check ClassCastException, ArrayIndexOutOfBoundsException, arithmetexception, unsupported operationexception and NullPointerException
When using Java, the problem is not an unchecked exception The examined exception is a controversial subject Some people say that this is mainly an experiment in Java. In practice, they don't work, but you will find that many people think they are very good
However, no one thinks the unchecked exception is bad
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码