Skip to content

Comments

Finished#1744

Open
Bakunau wants to merge 2 commits intomate-academy:masterfrom
Bakunau:master
Open

Finished#1744
Bakunau wants to merge 2 commits intomate-academy:masterfrom
Bakunau:master

Conversation

@Bakunau
Copy link

@Bakunau Bakunau commented Feb 9, 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.

Review Summary

You've built a solid foundation for the custom ArrayList, and the overall structure is well done. However, a few changes are needed to meet all the task requirements.

Here are the key points to address:

  1. Array Growth Factor: The internal array should grow 1.5 times its current size when full. Your implementation currently doubles it. Please adjust this logic and declare the growth factor as a constant.
  2. Use of System.arraycopy(): The requirements explicitly state to use System.arraycopy() for moving elements within the array (e.g., when adding or removing elements) and for copying elements to a new array during resizing. Your solution currently uses for loops for these operations. [CHECKLIST ITEM #8]
  3. Informative Exceptions: The NoSuchElementException should be thrown with a descriptive message explaining why the exception occurred. [CHECKLIST ITEM #10]

Please make these adjustments. You're very close to a complete solution!


✨ 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

Comment on lines 30 to 32
for (int i = size; i > index; i--) {
elements[i] = elements[i - 1];
}

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.' You should use System.arraycopy() to shift the elements to the right instead of a manual loop.

Comment on lines 69 to 71
for (int i = index; i < size - 1; i++) {
elements[i] = elements[i + 1];
}

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.' Please use System.arraycopy() to shift elements to the left after removing an element.

return remove(i);
}
}
throw new NoSuchElementException();

Choose a reason for hiding this comment

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

This violates checklist item #10: 'Make your exceptions informative.' The NoSuchElementException should be thrown with a descriptive message explaining why the exception occurred.


private void ensureCapacity() {
if (size == elements.length) {
Object[] newArray = new Object[elements.length * 2];

Choose a reason for hiding this comment

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

The task requires the internal array to grow 1.5 times when it's full. This implementation doubles the capacity (* 2), which does not meet the requirement. Also, the growth factor should be a constant.

Comment on lines 106 to 108
for (int i = 0; i < elements.length; i++) {
newArray[i] = elements[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.' You should use System.arraycopy() to copy elements to the new, larger array.

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

Excellent work on this revision! You've successfully addressed all the previous feedback, and your ArrayList implementation is now functionally complete and correct. I am approving your solution.

The build is failing due to a couple of minor style issues reported by checkstyle. Please fix them to get a green build:

  1. Declaration Order: Static variables like DEFAULT_CAPACITY and GROWTH_FACTOR should be declared before instance variables.
  2. Variable Usage Distance: In the remove(int index) method, the removed variable is declared a bit too far from its final use. You can fix this by combining the last two lines before the return into elements[--size] = null;.

Great job implementing the core logic and handling all the requirements!


✨ 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