Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanlavrinenko committed Jan 16, 2025
1 parent a172c59 commit 7c37ffb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/test/java/core/basesyntax/ArrayList.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package core.basesyntax;

import core.basesyntax.ArrayListIndexOutOfBoundsException;
import java.util.Arrays;
import java.util.NoSuchElementException;

Expand Down Expand Up @@ -80,13 +81,6 @@ private void ensureCapacity() {
}
}

private void ensureCapacity(int minCapacity) {
if (minCapacity > elements.length) {
int newCapacity = Math.max(elements.length * 2, minCapacity);
elements = Arrays.copyOf(elements, newCapacity);
}
}

private void validateIndex(int index) {
if (index < 0 || index >= size) {
throw new ArrayListIndexOutOfBoundsException("Index out of bounds: " + index);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package core.basesyntax;

public class ArrayListIndexOutOfBoundsException extends IndexOutOfBoundsException {
public class ArrayListIndexOutOfBoundsException extends RuntimeException {
public ArrayListIndexOutOfBoundsException(String message) {
super(message);
}
Expand Down

0 comments on commit 7c37ffb

Please sign in to comment.