Java provides two main types of exceptions: runtime exception and checked exception. Checked
Exceptions are the IO exceptions we often encounter and SQL exceptions. For this exception,
The Java compiler forces us to catch these exceptions. Therefore, in the face of such exceptions
Whether we are willing or not, we can only write a lot of catch blocks on our own to handle possible exceptions.
But there is another exception: runtime exception, also known as a runtime exception, which we can not handle
. When such an exception occurs, it is always taken over by the virtual machine. For example, we have never handled
Nullpointerexception is a running exception, which is the most common exception.
Common.
When an exception occurs during running, the system throws the exception to the upper layer and keeps processing the code. If
No processing block. To the top layer, thread. Run () throws multi-threading. If it is a single thread
Thrown by main. If the thread is thrown, the thread exits. If the main program throws
The program exits. An exception is a subclass of exception.
Can be processed by catch blocks. But we often don't handle it. That's it.
Yes. If you do not handle runtime exceptions, after a runtime exception occurs
Stop, or terminate the main program.
If you do not want to terminate, you must capture all running exceptions and never let the processing thread exit.
The exception data appears in the queue. The normal processing should be to discard the exception data and then record the log.
Normal data cannot be processed due to abnormal data. In this scenario, it may be
A good application does not mean that you should do this in all scenarios. In other scenarios,
When you encounter some errors, If you exit the program, you can ignore the running exception, or
The Controller exits by explicitly handling exceptions.