the difference between an exception and an error. Exception: In Java, the error of the program is mainly a syntax error and semantic error, a program in the compilation and runtime errors we call the exception, it is a VM (virtual machine) notify you a way, in this way, the VM let you know,
You (the developer) have made a mistake and now have a chance to modify it. Exception classes are used in Java to represent exceptions, and different exception classes represent different exceptions. But all exceptions in Java have a base class, called exception. Error: It refers to a serious problem that a reasonable application cannot intercept. Most of them are abnormal situations. The error is a failure of the VM (although it can be any system-level service). So, mistakes are hard to deal with,
It is not common for developers to handle these errors. For example, memory overflow; As with exceptions, the error class is used in Java to represent errors, and different error classes represent different errors. But all the errors in Java have a base class called error. In conclusion , we can know that the most essential difference between the anomaly and the error is that the exception can be handled by the developer and the error is the system originally brought, the general can not deal with or need our programmer to deal with. exception Classification in Java is divided into two major categories: Compiler exception and run exception running exception is runtimeexception; All the rest of the compiler exception in Java exception exception and error errors in Java have a common parent class throwable. Three, runtimeexception several sub-categories of the specific introduction1, java.lang.ArrayIndexOutOfBoundsException array index out-of-bounds exception. Thrown when the index value of an array is negative or greater than or equal to the size of the arrays. 2, java.lang.ArithmeticException arithmetic condition is abnormal. For example: integers except 0. 3, java.lang.NullPointerException null pointer exception. This exception is thrown when an app tries to use null where the object is required. Example: Invoking an instance method of a null object, accessing the properties of a null object, calculating the length of a null object, throwing null with a throw statement, and so on4, Java.lang.ClassNotFoundException cannot find a class exception. This exception is thrown when an application attempts to construct a class based on a class name in string form, and when a class file of the corresponding name is not found after traversing Classpah.
Exceptions and Errors in Java