Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashTable

 
Steven Leow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know what if i use put() to insert a value to an existing key?
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steven,
Last one in wins! It will replace the last object with the newer one.
Regards,
Manfred.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the up side, the put method does return the previous value. So if you get a null returned, you know you didn't overwrite something. But if you do replace another mapping, the old value is returned.
 
Steven Leow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the hasttable used in a chat program?
I mean the Key contains what? and the Values contains what? From what i know they contains things which enables the server to "look" for the clients...
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
there are lot of things to do with hashtables. what is it your looking for ? do you have a specific problem ?
you could use it to "map" a username to the ip/port (eg. for whsipering to a special user).

karl
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic