Null pointer access: The variable sList can only be null at this location
来源:互联网 发布:大道寺知世和知世公主 编辑:程序博客网 时间:2024/04/29 20:15
错误描述:nullPointException
错误背景:我创建了一临时变量ArrayList<File> fList=null,然后用它添加File对象。运行程序时报错,仅仅是浏览器报错,eclipse不报错。
问题分析:dList.add()下出现警告信息Null pointer access: The variable sList can only be null at this location;刚开始是并没有注意他,后来发现问题就出在他身上。
我创建临时变量ArrayList<File> fList=null,仅仅是声明了一变量,此时该变量仅仅在栈中,值为null,此时并没有指向对中的任何对象,但是我却用它添加对象,这是不可能完成的。
解决方案:ArrayList<File> fList=null改为:ArrayList<File> fList=new ArrayList<File>();
总结: 不要忽视警告信息,有时警告也是错误。
0 0
- Null pointer access: The variable sList can only be null at this location
- Null pointer access: The variable number can only be null at this location。 错误解决
- Null pointer access: The variable condition can only be null at this location。
- Null pointer access: The variable number can only be null at this location。 错误解决
- Null pointer access: The variable marketcommends can only be null at this location
- Warn:Null pointer access: The variable addressList can only be null at this location
- Null pointer access: The variable sb can only be null at this location
- Null pointer access: The variable temp can only be null at this location
- Null pointer access: The variable al can only be null at this location问题的解决
- Eclipse 代码检测报 Potential null pointer access: The variable XX may be null at this location
- mysql:Variable 'character_set_client' can't be set to the value of 'NULL'解决
- Variable ‘time_zone’ can’t be set to the value of ‘NULL’解决方法
- [mysql] 批量导入提示: Variable ‘character_set_client’ can’t be set to the value of ‘NULL
- [main]- ERROR 1037 Operands of Regex can be CharArray only :(Name: Regex Type: null Uid: null)
- null pointer at org.springframework.beans.PropertyEditorRegistrySupport
- Can a DateTime be null?
- why offsetof can use null pointer
- null pointer
- 《高性能MySQL》读书笔记--Schema与数据类型优化
- Mat转IplImage
- Windows访问Linux Samba的共享目录提示 登录失败:用户名或密码错误
- 判断每组是否是最后一个row
- iw命令移植(arm)
- Null pointer access: The variable sList can only be null at this location
- spark安装与调试
- 不使用Cygwin,在eclipse中快速开发JNI,一键生成C头文件.h,以及一键使用NDK交叉编译
- 如何用cmd命令控制mysql数据库
- 模拟人类大脑每秒计算数量级的估计
- protocol buffers在linux下的安装
- PHP 之 compact extract list
- 各种排序算法的比较
- 通知Android系统相册更新