Skip to content

Commit 3f74b3e

Browse files
committed
Code refactoring.
1 parent 6bb5753 commit 3f74b3e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/yurii/salimov/lesson08/task05/MyArrayList.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ public T get(final int index) {
8484
@Override
8585
public T set(final int index, final T object) {
8686
checkIndex(index);
87-
T value = (T) this.elementData[index];
87+
final T value = (T) this.elementData[index];
8888
this.elementData[index] = object;
8989
return value;
9090
}
9191

9292
@Override
9393
public T remove(final int index) {
9494
checkIndex(index);
95-
T value = (T) this.elementData[index];
96-
int numMoved = this.size - index - 1;
95+
final T value = (T) this.elementData[index];
96+
final int numMoved = this.size - index - 1;
9797
System.arraycopy(this.elementData, index + 1, this.elementData, index, numMoved);
9898
this.elementData[--this.size] = null;
9999
return value;
@@ -197,7 +197,7 @@ public boolean equals(final Object object) {
197197
if (this.getClass() != object.getClass()) {
198198
return false;
199199
}
200-
MyArrayList other = (MyArrayList) object;
200+
final MyArrayList other = (MyArrayList) object;
201201
if (this.size != other.size) {
202202
return false;
203203
}
@@ -216,7 +216,7 @@ public int hashCode() {
216216

217217
private void ensureCapacity(final int minCapacity) throws IndexOutOfBoundsException {
218218
if (minCapacity > this.elementData.length) {
219-
Object[] oldData = new Object[this.size];
219+
final Object[] oldData = new Object[this.size];
220220
System.arraycopy(this.elementData, 0, oldData, 0, this.size);
221221
int newCapacity = this.size * 3 / 2 + 1;
222222
this.elementData = new Object[newCapacity];

0 commit comments

Comments
 (0)