Skip to content

Comments

I did#1748

Closed
Yehor0820 wants to merge 2 commits intomate-academy:masterfrom
Yehor0820:hw-10
Closed

I did#1748
Yehor0820 wants to merge 2 commits intomate-academy:masterfrom
Yehor0820:hw-10

Conversation

@Yehor0820
Copy link

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.

Review Summary

I am requesting changes because there are still a few explicit checklist violations that must be fixed before this task can be considered complete. Functionally your ArrayList implementation is solid (correct default capacity, 1.5x growth, custom exceptions, and required methods), but the checklist is part of the core requirements for this task.

Critical issues that must be fixed:

  1. There is a redundant blank line at the start of the class implementation in src/main/java/core/basesyntax/ArrayList.java (just before the constructor), which violates [CHECKLIST ITEM #1]; remove any leading empty lines directly inside the class or method bodies.
  2. The resize logic currently uses a hardcoded 2 in elements.length + elements.length / 2; per [CHECKLIST ITEM #3], extract this growth factor into a clearly named constant (for example, private static final int GROWTH_DIVISOR = 2;) and use it in the calculation.
  3. In ensureCapacity(), you copy elements with a manual for loop; [CHECKLIST ITEM #8] requires using System.arraycopy, so replace the loop with something like System.arraycopy(elements, 0, newArray, 0, elements.length).

Minor (non-blocking) improvement: in add(value, index) you could validate the index before calling ensureCapacity() to avoid unnecessary resizing. Once you address the three checklist issues above, your solution will fully meet both functional and style requirements for this task.


✨ 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

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

Choose a reason for hiding this comment

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

This violates checklist item #1: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines." There is a redundant empty line immediately before the constructor; remove redundant blank lines that begin class/method implementations to satisfy the checklist.


private void ensureCapacity() {
if (size == elements.length) {
int newSize = elements.length + elements.length / 2;

Choose a reason for hiding this comment

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

This violates checklist item #3: "Any magic numbers should be constants\nYour code should be easy to read. Move all hardcoded values to constant fields and give them informative names." The growth calculation uses the literal 2 in elements.length + elements.length / 2. Extract the growth factor into a named constant (for example GROWTH_DIVISOR or GROWTH_MULTIPLIER) and use it in the resize calculation.

int newSize = elements.length + elements.length / 2;
Object[] newArray = new Object[newSize];

for (int i = 0; i < elements.length; i++) {

Choose a reason for hiding this comment

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

This violates checklist item #8: "Use [System.arraycopy()] to move your array elements." In ensureCapacity() you copy elements with an explicit for-loop; replace the loop with System.arraycopy(elements, 0, newArray, 0, elements.length) so element movement uses the required API.

@Yehor0820 Yehor0820 closed this by deleting the head repository Feb 11, 2026
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