异常分为两种:

1.编译时异常

当编译时异常抛出时,需要对其进行处理声明,否则编译不通过

 

2.运行时异常

编译时不检测,运行时 如果抛出,程序会立刻停止

 

NullPointerException 空指针引用异常

ClassCastException 类型转换异常

IllegalArgumentException 非法参数异常

ArithmeticException 算数运算异常

IndexOutOfBoundsException 下标越界异常

NumberFormatException 数字格式异常

SecurityException 安全异常

 

Android Force Close 出现的原因,常见的比如空指针,类没有找到,资源没找到,Android API的使用顺序错误等

实现Thread.UncaughtExceptionHandler接口,重写uncaughtException()方法

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-01-23
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2021-11-17
  • 2021-07-19
猜你喜欢
  • 2021-11-28
  • 2022-12-23
  • 2021-12-01
相关资源
相似解决方案