list#1779
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because, while your ArrayList implementation is functionally correct and meets the core behavioral requirements, there are still a few checklist and style violations that must be resolved before it can be considered complete. The most important one is in remove(T element), where you throw new NoSuchElementException() without any message; per the checklist [CHECKLIST ITEM #10], this exception must include an informative message, for example new NoSuchElementException("Element not found: " + element) so stack traces are clear. You also need to remove redundant leading empty lines inside the class: do not start the class body or any method body (such as before ensureCapacity()) with a blank line, as this violates [CHECKLIST ITEM #1]. Separately, fix the Checkstyle issues it flagged: add a blank line between the last field and the constructor (around line 10) and between the last field and the first method (around line 28), and ensure there are spaces around the == operator (e.g., change if (index==size) to if (index == size) near line 101). These are mostly mechanical edits, but they are required because they currently cause style checks to fail and break the checklist rules. Once you address these points, your solution will fully align with both the functional requirements and the style/checklist expectations—you're very close, so this is a good opportunity to polish the code to the required standard.
✨ 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
| import java.util.NoSuchElementException; | ||
|
|
||
| public class ArrayList<T> implements List<T> { | ||
|
|
There was a problem hiding this comment.
This violates checklist item #1: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is an empty line immediately after the class declaration. Remove the redundant blank line so the class body starts directly with the fields/first statement.
| public ArrayList() { | ||
| elementData = new Object[DEFAULT_CAPACITY]; | ||
| } | ||
|
|
There was a problem hiding this comment.
This violates checklist item #1: "Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :)" — there is a redundant empty line immediately before the start of the ensureCapacity() method. Remove that blank line so the method declaration is not preceded by an extra empty line.
| return removed; | ||
| } | ||
| } | ||
| throw new NoSuchElementException(); |
There was a problem hiding this comment.
This violates checklist item #10: "Make your exceptions informative. If you throw an Exception, you should always add an informative message so that it would be clear from the stack trace what exactly went wrong." — the NoSuchElementException thrown in remove(T element) has no message. Add an informative message (for example: "Element not found: " + element) so the stack trace is helpful.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because your custom ArrayList<T> correctly implements the List<T> interface and satisfies the specified behavioral requirements. You use a default capacity of 10, grow the internal array by 1.5x, and rely on System.arraycopy for shifting elements and resizing, which matches the task constraints. Index validation is cleanly extracted into private helper methods that throw the required ArrayListIndexOutOfBoundsException with informative messages, and remove(T element) properly throws a NoSuchElementException when the element is not found. The implementation avoids disallowed utility classes and keeps variable and method names clear and descriptive. Overall, the code is functionally sound, aligned with the checklist, and well-structured, so no blocking issues remain.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.