-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented class StorageImpl with methods put, get, equals #1664
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your implementation of StorageImpl
is well-structured and meets the core requirements of the task. 🎉 While there are a few areas for improvement, such as handling the storage limit more gracefully and addressing type safety with generic arrays, these are minor issues that don't significantly impact the functionality. Keep up the great work, and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
private int storageSize = 0; | ||
|
||
public StorageImpl() { | ||
keys = (K[]) new Object[MaxStorageSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to a generic array like (K[]) new Object[MaxStorageSize]
is not type-safe and can lead to ClassCastException
at runtime. Consider using a different approach, such as using an ArrayList
or handling the array differently to avoid this issue.
|
||
public StorageImpl() { | ||
keys = (K[]) new Object[MaxStorageSize]; | ||
values = (V[]) new Object[MaxStorageSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the keys array, casting to (V[]) new Object[MaxStorageSize]
is not type-safe. Consider using a different approach to avoid potential runtime exceptions.
this.values[storageSize] = value; | ||
storageSize++; | ||
} else { | ||
System.out.println("The limit of storage is 10"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Printing a message to the console is not the best way to handle the situation when the storage limit is reached. Consider throwing an exception or using a logging framework to handle this scenario more gracefully.
No description provided.