当前位置:网站首页>异常处理(一)——空指针和数组索引越界
异常处理(一)——空指针和数组索引越界
2022-06-28 06:04:00 【木棣%】
NullPointerException
遇到的最多的错误。用debug一步一步的跳转排除,有时可能是括号加错了位置,可能是调错了方法中的参数,所以在书写的时候要认真检查,尽可能避免空指针异常带来的错误。

while循环判断完应该进入for循环,括号的位置出错导致最终判断结果为null,即空指针异常调用对象中的
getGameId()方法,比较是否相等,误书写成了player.equals(gameId)造成了空指针异常

检查了好久都检查不出来,后来才发现是if语句判断的时候player2已经为null了,所以调用playerDao.addPlayer()时我不能再添加这个空的,而是新录入的player
ArrayIndexOutOfBoundsException


元素格式前后不照应
边栏推荐
- Prime mover × Cloud primordial is making sound, reducing cost and increasing efficiency lecture hall
- Mosaic data enhanced mosaic
- 脚本语言和编程语言
- Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
- lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
- Valueerror: iterative over raw text documents expected, string object received
- numpy. reshape, numpy. Understanding of transfer
- idea根据数据库表生成实体类
- Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
- Use the SQL SELECT count distinct query statement to count the total number of unique values of a field in the database
猜你喜欢
随机推荐
AutoCAD C# 多段線小銳角檢測
Data warehouse: financial / banking theme layer division scheme
Xcode13.3.1 error reported after pod install
bash install. SH ******** error
V4l2 driver layer analysis
pytorch dataloader的长度 epoch与iteration的区别
easyui 重置多条件查询
【无标题】
Development trend of mobile advertising: Leveraging stock and fine marketing
pkg打包node工程(express)
Select trigger event from easyUI drop-down box
Filecoin hacker song developer competition
不会还有人只会用forEach遍历数组吧?
API learning of OpenGL (2007) gltexcoordpointer
sql及list去重操作
Working principle of es9023 audio decoding chip
19 fonctions de perte d'apprentissage profond
mac下安装多个版本php并且进行管理
Sklearn Feature Engineering (summary)
MySQL common functions









