use*_*237 2 java android indexoutofboundsexception
为什么会ArrayIndexOutOfBoundsException出现以及如何在Android中避免它?
当您尝试访问不存在的数组项时,抛出此异常:
String [] myArray = new String[2];
myArray[2] = "something"; // Throws exception
myArray[-1] = "something"; // Throws exception
Run Code Online (Sandbox Code Playgroud)
在访问数组项之前,应检查索引是否为负数且不高于数组长度.
| 归档时间: |
|
| 查看次数: |
34976 次 |
| 最近记录: |