Skip to content

Comments

mvn complete#1735

Open
qreqit wants to merge 1 commit intomate-academy:masterfrom
qreqit:master
Open

mvn complete#1735
qreqit wants to merge 1 commit intomate-academy:masterfrom
qreqit:master

Conversation

@qreqit
Copy link

@qreqit qreqit commented Jan 26, 2026

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

The test task has already been approved.
[CODE: AAP]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

The test task has already been approved.
[CODE: AAP]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

The test task has already been approved.
[CODE: AAP]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

The test task has already been approved.
[CODE: AAP]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@Elena-Bruyako Elena-Bruyako left a comment

Choose a reason for hiding this comment

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

see comments


public class ArrayList<T> implements List<T> {
private static final int DEFAULT_CAPACITY = 10;
private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = new Object[0];

Choose a reason for hiding this comment

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

remove redundant variable

import java.util.NoSuchElementException;

public class ArrayList<T> implements List<T> {
private static final int DEFAULT_CAPACITY = 10;

Choose a reason for hiding this comment

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

Suggested change
private static final int DEFAULT_CAPACITY = 10;
private static final int DEFAULT_CAPACITY = 10;
private static final double CAPACITY_INDEX = 1.5;


public ArrayList() {
size = 0;
this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;

Choose a reason for hiding this comment

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

Suggested change
this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
elements = new Object[DEFAULT_CAPACITY];

@Override
public void add(T value, int index) {

if ((index < 0) || (index > size)) {

Choose a reason for hiding this comment

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

Suggested change
if ((index < 0) || (index > size)) {
if (index < 0 || index > size) {

Comment on lines +42 to +44
if (list == null) {
throw new RuntimeException("Can not add list");
}

Choose a reason for hiding this comment

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

Suggested change
if (list == null) {
throw new RuntimeException("Can not add list");
}

@Override
public T get(int index) {
return null;
if (index < 0 || index >= size) {

Choose a reason for hiding this comment

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

avoid duplication of code and create separate method

@Override
public T remove(T element) {
return null;
int indexOfElement = -1;

Choose a reason for hiding this comment

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

Suggested change
int indexOfElement = -1;
int index = index(element);
if (index == -1) {
throw new NoSuchElementException("There is no such element in the list, " + element);
}
return remove(index);

where

private int index(T element) {
        int index = -1;
        for (int i = 0; i < size; i++) {
            if (elements[i] == element
                    || elements[i] != null && elements[i].equals(element)) {
                index = i;
            }
        }
        return index;
    }

return size == 0;
}

private Object[] grow(int minCapacity) {

Choose a reason for hiding this comment

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

see the example of resize method

if (elements.length == size) {
            int newCapacity = (int) (elements.length * CAPACITY_INDEX);
            Object[] newArray = new Object[newCapacity];
            System.arraycopy(elements, 0, newArray, 0, size);
            elements = newArray;
        }

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.

3 participants