complete task#1907
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because it correctly implements a generic key–value storage with put, get, and size using two arrays, with MAX_SIZE = 10, and it properly replaces values when a key is re‑used. The use of a private helper (like findKeyIndex) keeps the code DRY, and your handling of null keys and generic typing is consistent and clear. All core requirements are met: arrays are initialized in the constructor, there are no forbidden collections or Objects usage, and size() accurately reflects the number of stored entries.
One minor improvement area: in your put method, when you add a new key with something like keys[size] = key; values[size] = value; size++;, there is no explicit guard to prevent writing beyond the array when more than 10 distinct keys are inserted, which would lead to an ArrayIndexOutOfBoundsException. Given the task’s constraint of a maximum of 10 elements, this is acceptable for the current requirements, but you could defensively check if (size < MAX_SIZE) before inserting and decide how to handle the “full storage” case (e.g., ignore the new pair or overwrite some entry). Overall, your implementation is clean, readable, and functionally correct for the specified constraints—well done.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.