aspose file tools*
The moose likes Beginning Java and the fly likes HashTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HashTable" Watch "HashTable" New topic
Author

HashTable

Steven Leow
Greenhorn

Joined: Jun 19, 2001
Posts: 6
Does anyone know what if i use put() to insert a value to an existing key?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Steven,
Last one in wins! It will replace the last object with the newer one.
Regards,
Manfred.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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

Joined: Jun 19, 2001
Posts: 6
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

Joined: May 25, 2001
Posts: 388
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
 
jQuery in Action, 2nd edition
 
subject: HashTable