Skip to content

Commit de66e5d

Browse files
committed
更新readme
1 parent 690c1b5 commit de66e5d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

MD/ArrayList.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,23 @@
7070
}
7171
```
7272

73+
以及指定位置插入数据:
74+
```java
75+
public void add(int index, E element) {
76+
insertElementAt(element, index);
77+
}
78+
public synchronized void insertElementAt(E obj, int index) {
79+
modCount++;
80+
if (index > elementCount) {
81+
throw new ArrayIndexOutOfBoundsException(index
82+
+ " > " + elementCount);
83+
}
84+
ensureCapacityHelper(elementCount + 1);
85+
System.arraycopy(elementData, index, elementData, index + 1, elementCount - index);
86+
elementData[index] = obj;
87+
elementCount++;
88+
}
89+
```
90+
91+
7392

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Java 面试常见题型
22

33
### Java 基础
4-
[ArrayList 底层分析](https://github.com/crossoverJie/Java-Interview/blob/master/MD/ArrayList.md)
4+
[ArrayList/Vector 底层分析](https://github.com/crossoverJie/Java-Interview/blob/master/MD/ArrayList.md)
55

66
### Java 多线程
77
- [多线程中的常见问题](https://github.com/crossoverJie/Java-Interview/blob/master/MD/Thread-common-problem.md)

0 commit comments

Comments
 (0)