Java encapsulates all errors as an object with the root parent class Throwable.
There are two subcategories of Throwable: Error and exception.
An Error object indicates a program error, which refers to the underlying, low-level, unrecoverable, critical error. At this point the program must exit because it has lost the physical environment necessary to run.
We cannot handle error errors because we are using the program to deal with errors, but the program has exited.
There are only exception objects (exceptions/exceptions) in the Throwable object that we can handle.
Exception has two sub-classes: Runtime Exception (Exception not checked)
Non-runtime exception (checked for exceptions)
(Note: Whether the exception is not checked or the check exception is not found at compile time, during compilation, the program's syntax error is checked, and the exception is the concept of a run-time program error.) )
In exception, all non-unchecked exceptions are checked for exceptions, no additional exceptions!!
The exception was not checked because the programmer did not perform the necessary checks because of his negligence and errors caused by the exception. Must be an exception within the virtual machine (such as a null pointer).
1 PackageTomtext;2 //the assignment between the test objects. 3 Public classtomtext_46 {4 inti;5 Public Static voidmain (String [] a) {6tomtext_46 n1=Newtomtext_46 ();7tomtext_46 n2=Newtomtext_46 ();8N1.i=9;9n2.i=47;TenSystem.out.println ("n1.i=" +n1.i+ "\t\t" + "n2.i=" +n2.i); Onen1=N2; ASystem.out.println ("n1.i=" +n1.i+ "\t\t" + "n2.i=" +n2.i); -N1.i=27; -System.out.println ("n1.i=" +n1.i+ "\t\t" + "n2.i=" +n2.i); the } - -}
Java encapsulates all errors as an object with the root parent class Throwable