• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding objects to HashMap that have duplicate keys

 
Rachel Glenn
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a HashMap, and I call .put() several times with the same key..for example..



Then the first put() call will return true and the second put() call will return false because the "Monday" key already exists?
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put doesn't return a boolean. put returns the previous value. So, first call will return null and second call will return the first object
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic