From the oldest programming language, error control has always been a big problem that designers need to solve. Because it is difficult to design a perfect set of error control schemes, many languages simply ignore the problem and pass it on to the library designer. The main problem with most error-control scenarios is that they rely heavily on the programmer's alertness rather than on the language's own mandatory standards. If programmers are not vigilant-and if they are in a hurry, this is almost certainly happening-the error-control programs on which the program relies will fail.
"Unauthorized control" is built into the programming language, and sometimes even inside the operating system, by the error control scheme. The "violation" (Exception) here is a special object that "throws" or "throws" from the place where the error occurred. The violation is then designed to control the "unauthorized controller" capture of a particular type of error. When things get out of hand, there may be several unauthorized controllers that catch the corresponding offending object in parallel. As a standalone execution path is used, it does not interfere with our regular execution code. This makes the code easier to write because it doesn't have to be mandatory to check the code regularly. In addition to this, a "throw" violation is different from the error value returned from the function, or a flag set by the function. The effect of those error values or flags is to indicate an error state, which can be ignored. But the offence cannot be ignored, so it can certainly be disposed of somewhere. Finally, the use of violations can reliably recover from a bad environment. At this time generally do not need to exit, we can take some processing, restore the normal execution of the program. Obviously, the program is more reliable.
Java's illegal control mechanism differs from most programming languages. Because in Java, the offending control module is encapsulated from the very beginning, so it must be used! If you do not write some code to control the violation correctly, you will get a compile-time error message. This ensures the continuity of the program and makes error control easier.
Note that illegal control is not an object-oriented feature, although in an object-oriented programming language, an offence is usually represented by an object. Prior to the advent of object-oriented languages, unauthorized control was already in existence.