File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HashTable" Watch "HashTable" New topic


Steven Leow

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.
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

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
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).

I agree. Here's the link:
subject: HashTable
It's not a secret anymore!