Five common types of anomalies
1. NullPointerException NULL pointer
2. ClassNotFoundException specified class does not exist
3. ArithmeticException Operation exception
4, arrayindexoutofboundsexception array subscript out of bounds
5. Parameter error of IllegalArgumentException method
6, Illegalaccessexception No access rights
Small example
Import Java.util.scanner;public class Exception { int shang; Public Exception (int chushu,int beichushu) { shang=chushu/beichushu; } public static void Main (string[] args) { try { Scanner sc=new Scanner (system.in); String Chushu=sc.nextline (); String beichushu=sc.nextline (); int a =integer.parseint (chushu); int b =integer.parseint (Beichushu); Exception Exception =new Exception (A, b); System.out.println (Exception.shang);} catch (NumberFormatException e) {System.out.println ("numberformatexception"); E.printstacktrace ();//Todo:handle Exception} catch (ArithmeticException e) { System.out.println ("ArithmeticException");//Todo:handle Exception e.printstacktrace ();} finally {System.out.println ("666");}}}
Java Basics-Exceptions