Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed jv-array-list #1208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

BraiXen-rar
Copy link

I may not have been able to adhere to all the "Try to avoid these common mistakes while solving task", but the task was not easy. I hope for your help if you find any mistakes

Copy link

@Ivan95kos Ivan95kos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job overall!

public class ArrayList<T> implements List<T> {

private static final int DEFAULT_CAPACITY = 10;
private Object[] elements;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the parameterized type

Suggested change
private Object[] elements;
private T [] elements;

public class ArrayList<T> implements List<T> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line

Suggested change

Comment on lines 48 to 50
if (index < 0 || index >= size) {
throw new ArrayListIndexOutOfBoundsException("Index is out of bounds");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to a private method checkIndex(int index)
you use this check three times

Suggested change
if (index < 0 || index >= size) {
throw new ArrayListIndexOutOfBoundsException("Index is out of bounds");
}
if (index < 0 || index >= size) {
throw new ArrayListIndexOutOfBoundsException("Index is out of bounds: " + index);
}


private int indexOf(T element) {
for (int i = 0; i < size; i++) {
if (Objects.equals(elements[i], element)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BraiXen-rar BraiXen-rar requested a review from Ivan95kos November 2, 2023 12:51
Copy link

@Ivan95kos Ivan95kos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants