java - Java数组列表实现中Object[] es = elementData的目的是什么
问题描述
在 Array List 实现中,我们有这段代码。对象数组的目的是什么?为什么使用它,为什么不对 elementData 本身执行操作?
int indexOfRange(Object o, int start, int end) {
Object[] es = elementData;
if (o == null) {
for (int i = start; i < end; i++) {
if (es[i] == null) {
return i;
}
}
} else {
for (int i = start; i < end; i++) {
if (o.equals(es[i])) {
return i;
}
}
}
return -1;
}
解决方案
推荐阅读
- python - 在 Python 中检测星星
- typescript - 使用正文在 post 请求上指定 Axios 响应类型
- reactjs - 在后端连接中反应应用程序 cors 错误
- c# - 向 CsvHelper.Configuration.ClassMap 对象添加验证(字符串)
- flutter - Null 值正在保存,而不是 Flutter 中输入的值
- php - PHP/HTML 表格行在按下更新按钮时不会更改为表单
- python - 将字符串日期和时间转换为火花数据框中的时间戳
- scala - 在 Spark Databricks (scala) 中写入/读取/删除二进制数据
- pentaho - Pentaho - 搜索 xml 文件
- udp - skb_tail_pointer(skb) 无法正常工作。并错误地指向 udp 标头尾部