我试图为我的数据数组找到合适的数据结构。我更喜欢支持插入操作的(在列表中间插入)。
如果没有这样的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/