Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What is the requirement for an object to be used as key or value in HashMap?
Home
DBMS
What is the requirement for an object to be used as key or value in HashMap?
0
votes
asked
Aug 10, 2023
in
DBMS
by
DavidAnderson
What is the requirement for an object to be used as key or value in HashMap?
dbms
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Aug 10, 2023
by
DavidAnderson
The key or value object that gets used in the hashmap must implement
equals()
and
hashcode()
method.
The hash code is used when inserting the key object into the map and the equals method is used when trying to retrieve a value from the map.
...