Overall structure:
Java.lang.Throwable
Java.lang.Error
Java.lang.Exception
Java.lang.RuntimeException
Compile-time exception is a inspected exception (checked)
1. Exception: Abnormal behavior occurs during the execution of the program, the programmer can capture processing
Error: An exception that is not expected to be caught by the user, such as corruption of computer hardware, memory overflow.
2. Compile-time Exception: The exception that is generated when the. Java source file executes the. javac command
Run-time Exception: The exception that is generated when the. Class bytecode file executes the. java command.
Java requires that a compile-time exception be handled, but does not require that a run-time exception be handled that is not caught.
3. Exception handling: The object-oriented approach to exception processing, the various types of anomalies are categorized, and provides a good interface.
In Java, each exception is an object, which is an instance of the Throwable class or its subclasses.
Can be passed Try...catch () ... The exception is handled in a way that can be throws by throwing the exception object to its caller and being handled by its callers.
You can actively throw an exception by using the Throw keyword.
4.throw: Use the inside of a method to throw an exception object actively
Throws: Used at the declaration of a method, is a way of exception handling that throws an exception to its caller, which is handled by the caller.
5. When the exception handling is complete, it is reclaimed during the next garbage collection.
6. Note the timing of the finally statement block execution, especially if there is a return statement in the try and catch blocks.
7. Custom Exceptions:
Class MyException extends exception{private static final long serialversionuid = 1650608766435423666l;public myexception () {}public myexception (String message) {super (message);}}
8. Several common compile-time exceptions:
FileNotFoundException: Occurs when a file is read into the stream
ClassNotFoundException: The class may not be found when deserializing
IOException: Occurs when a stream reads and writes
SQLException: I haven't met you yet.
ParseException: When a string is converted by a date format that is established by the SimpleDateFormat object.
9. Several common run- time Exceptions :
nullpointexception: Empty Object when invoking a method with a reference
String str = "n"; str = null; System.out.println (Str.tostring ());
arrayindexoutofboundsexception: Array subscript out of bounds
int[] arr = new INT[10]; System.out.println (arr[10]);
ClassCastException: When down transformation
Object obj = new Object (); String string = (string) obj; System.out.println (string);
ArithmeticException: An arithmetic exception, such as a divisor of 0
System.out.println (13/0);
IllegalArgumentException: Illegal parameters
Nosuchelementexception: Direct call to Iterator.next () throws this exception inputmismatchexception:scanner/sacnner.nextint () input non-numeric characters are thrown when typing
Invalidclassexception: Deserialization exception, no sequence number specified, class file modified
May be deficient, ready to add.
I'll be taking the time tomorrow. Summary of the collection, generics, IO part, it's too late today. Come on!
Javase: Exception Summary (Exception)