java - Java中哪些List实现支持插入操作?

标签 java arrays list linked-list

我试图为我的数据数组找到合适的数据结构。我更喜欢支持插入操作的(在列表中间插入)。

如果没有这样的Java内置数据结构,有什么好的实现方法呢?

例如如果我使用 ArrayList<String> ,好像不支持在列表中间插入,如何实现insert(int pos, String str)以一种好的方式?

最佳答案

查看 ArrayList.add方法(在 ArrayList 实现的 List 接口(interface)中声明)

Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

关于java - Java中哪些List实现支持插入操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12906754/

相关文章:

java - 如何删除cookies?

java - 如何在Java MySQL中统计数据

javascript - 检测数组中的任何元素是否包含连字符

java - 用于实现 DBMS 的数组/列表 (Java)

python - 为什么 pytest 中的列表与控制台的输出不同?

java - 只显示小数点后两位数

arrays - Laravel 集合 - 返回对象数组

javascript - 行为异常的数组

java - 通过 Spring Batch 作业步骤维护作业前对象

java - android java不显示任何布局