#Cannot invoke "getKey()" because "tan element is null but I need to allow null keys
16 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @harsh gate! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
also I cannot use collections framework that's why I created a Pair class with "key" and "value" fields
have u heard of preconditions??
public void put(Integer key, Box) {
if (key == null) throw new IllegalArgumentException("Storage key value may not be null");
...
}
or.... but this isnt recommended, code that does nothing for no visible reason is not a good idea
public void put(Integer key, Box) {
if (key == null) return; //cannot add an element with a null key, ignore
...
}
u should have learnt about preconditions how to use them and why they exist when learning about javadoccing ur code
I cannot handle null like this
"Method get(null) should return value""
Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click I'm done here. Close this post!.
probably an empty box in that case
Oh sorry I thought I closed the post and deleted it
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
the task is solved thanks
why do u have multiple asserts in a single test without any goal for the test?
the task is solved thanks