checked exception
Checked exceptions–occurs at the compile time–compile time exceptions
File file = new File(“E://file.txt”);
FileReader fr = new FileReader(file);
必须捕获或抛出FileNotFoundException否则编译不能通过
Unchecked exception
Unchecked exceptions–occurs at the time of execution–Runtime Exceptions
int num[] = {1, 2, 3, 4};
System.out.println(num[5]);
运行时报java.lang.ArrayIndexOutOfBoundsException
Errors
Errors–beyond the control of the user or the programmer–also ignored at the time of compilation
Errors are generated to indicate errors generated by the runtime environment. Example: JVM is out of memory. Normally, programs cannot recover from errors.
另一种分类
JVM Exceptions −
These are exceptions/errors that are exclusively or logically thrown by the JVM.
Examples: NullPointerException, ArrayIndexOutOfBoundsException, ClassCastException.
Programmatic Exceptions − These exceptions are thrown explicitly by the application or the API programmers. Examples: IllegalArgumentException, IllegalStateException.