ClassNotLoadedException(NullPointerException)
2016-02-24 09:37
337 查看
try {
System.out.println( arr[(Integer) null]);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这种方式使用数组会跑Nullpointer异常那个,因为数组中无null位置的元素。并且查看具体异常的跟踪信息(stackTrace),显示如下:
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
同理,无法使用这种方式 byte b = (Byte) null ;(同理Integer、Long等整数类型封装类)
无法将null转型为byte;
因为
byte内部又做缓存,同样也会导致上面数组那样的空指针。
public static Byte valueOf(byte b) {
final int offset = 128;
return ByteCache.cache[(int)b + offset];
}
System.out.println( arr[(Integer) null]);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这种方式使用数组会跑Nullpointer异常那个,因为数组中无null位置的元素。并且查看具体异常的跟踪信息(stackTrace),显示如下:
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
同理,无法使用这种方式 byte b = (Byte) null ;(同理Integer、Long等整数类型封装类)
无法将null转型为byte;
因为
byte内部又做缓存,同样也会导致上面数组那样的空指针。
public static Byte valueOf(byte b) {
final int offset = 128;
return ByteCache.cache[(int)b + offset];
}
相关文章推荐
- Ruby中的异常处理代码编写示例
- MySQL抛出Incorrect string value异常分析
- 浅谈C#中简单的异常引发与处理操作
- 详解C#编程中异常的创建和引发以及异常处理
- 详解JavaScript中的异常处理方法
- java程序中的延时加载异常及解决方案
- 解析Java异常的栈轨迹及其相关方法
- .NET(C#):Emit创建异常处理的方法
- windows7服务器上weblogic启动失败异常解决方法
- 有关ajax的error与后台的异常问题解决
- Zend Studio for Eclipse的java.lang.NullPointerException错误的解决方法
- 深入探讨JAVA中的异常与错误处理
- GO语言异常处理机制panic和recover分析
- 浅谈JAVA 异常对于性能的影响
- 解析C++编程中的bad_cast异常
- C++ 异常处理 catch(...)介绍
- php中异常处理方法小结
- PHP中异常处理的一些方法整理
- 浅析Lua编程中的异常处理
- Perl中捕获警告信息、异常信息并写入日志详解