首页 > 编程知识 正文

java数组未赋值输出什么,java二维数组

时间:2023-05-04 03:48:41 阅读:19304 作者:1058

在JAVA中使用数组的注意事项:

1. NullPointerException空指针

NullPointerException在开发过程中经常遇到,例如引用的对象为空,数组为空。

数组NullPointerException

不能为空数组元素赋值或获取长度。 否则,我就报告你

nullpointerexception : attempttowritetonullarray和

nullpointerexceptionattempttogetlengthofnullarray在以下代码中引起上面两种空指针的异常:

数组NullPointerException Log示例

Log信息如下

第一次使用NullPointerException如下

2020-03-2117336005336014.170 eandroidruntime : caused by : Java.lang.nullpointerexception : attempttogetlengthof

17:05:14.170.62788398839 eandroidruntime : atcom.program Android.exception.nullpointerexception.araynullpon

2 .使用数组时,在判断数组的长度后,首先需要判断是否为空。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。