Java教程

nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

本文主要是介绍nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、报错

nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

二、解决

https://blog.csdn.net/weixin_39274753/article/details/79709830

三、总结(引用上文的总结)

在往数据库添加数据需要判断数据库中是否已有记录,判断的返回结果通常是List。在List为空的情况下,调用其方法需要格外注意,例如:调用get()则会报下标越界的异常。

当然还可以联想到其他情况,当判断数组、集合为空后,注意不要取其中内容,不然就会报上述错误。

这篇关于nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!