JAVA程序常见异常

异常类                                                   含义                                                                  原因
NullPointerException                       空指针异常                                           一个引用类的赋值是一个null
                                                                                                                            引用类型调用了方法/属性

ArrayIndexOutBoundsException  数组(下标)越界异常                          访问数组下标是,出现<0>=数组长度

StringIndexOutBoundsException 字符串(下标)越界异常                      访问字符串下标时,出现<0>=字符串长度

classCastException                       强制类型转换异常                                      转换了非当前对象的类型

NumberFormatException             数据格式化异常                                       new Interger(“12a”);

ArithenmticException                       算数异常                                                 除数为0

InputMistmatchException                   输入异常                                       Scanner input=new Scanner(System.in);
                                                                                                                    int a=input.nextInt();    //输入为“a”

 

猜你喜欢

转载自blog.csdn.net/a_123gogo/article/details/84851243