1. What is an exception
what is an exception
Terminal the event of normal instruction flow
errors generated by the program during operation are called exceptions.
syntactically correct error in operation
2. Classification of exceptions
The virtual opportunity generates an exception object when the program generates an exception
all of the exception classes are sub-class of Throw ble
exceptions are divided into two main categories:
ERRor: Error, which occurs when the virtual machine is running, and when an error occurs, the virtual machine shuts down directly
Exception: Exception
Exception are divided into two main categories:
run-time exception Runtimeexception(uncheck exception)
Compile-time exception (Check exception)
If check exception is likely to occur in a piece of code , then the Java compiler will force the code to be handled abnormally.
For example: ThRead.sleep (+);
3.try.How to use the catch.finally structure
try{
Put code that might have an exception
}catch (Exception e) {
e.printstacktrace ();
}finally{
regardless of whether an exception occurs, it will be executed
}
Exceptions in Java