Skip to content

passed checkstyle and tests#1795

Open
acidden wants to merge 2 commits into
mate-academy:masterfrom
acidden:master
Open

passed checkstyle and tests#1795
acidden wants to merge 2 commits into
mate-academy:masterfrom
acidden:master

Conversation

@acidden
Copy link
Copy Markdown

@acidden acidden commented May 25, 2026

No description provided.

Copy link
Copy Markdown

@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.

Review Summary

This implementation has two critical violations of the task requirements that must be fixed before approval. First, the code imports and uses java.util.Arrays (line 3) and calls Arrays.copyOf() in the ensureCapacity() method, which explicitly violates the technical constraint 'Do not use Objects, Arrays, or any other util class.' You must replace this with a manual implementation using System.arraycopy() to create a new array and copy elements. Second, the constructor initializes the internal array with new Object[DEFAULT_CAPACITY], pre-allocating 10 elements. This differs from java.util.ArrayList behavior, which starts with an empty internal array—capacity 10 should only be allocated when the first element is added (lazy initialization). Please fix both issues and resubmit.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@@ -1,48 +1,119 @@
package core.basesyntax;

import java.util.Arrays;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates the technical constraint: 'Do not use Objects, Arrays, or any other util class.' The task explicitly prohibits using the Arrays class. Use System.arraycopy() to copy arrays instead of Arrays.copyOf().

private int size;

public ArrayList() {
this.elementData = new Object[DEFAULT_CAPACITY];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the task requirements, the default capacity should match java.util.ArrayList behavior which starts with an EMPTY internal array. The capacity should become 10 only when the first element is added (via ensureCapacity logic), not pre-allocated in the constructor.

: (int) (elementData.length * 1.5);
if (newLength < minCapacity) {
newLength = minCapacity;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace Arrays.copyOf() with a manual implementation using System.arraycopy() to avoid using the Arrays class. Create a new temporary array and copy elements manually.

Copy link
Copy Markdown

@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.

Review Summary

Your ArrayList implementation is approved and meets all requirements. The code successfully implements lazy initialization in the constructor (empty array created, capacity allocated only when needed), uses System.arraycopy() for array operations, and includes all required functionality: default capacity of 10 with 1.5x growth factor, proper exception handling for invalid indices and missing elements, and extracted helper methods for index validation and capacity management. All checklist items pass, and no test failures were reported. Great work addressing the previous review feedback!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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