wood burning stoves*
The moose likes Beginning Java and the fly likes Hash Tables, Hash Sets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hash Tables, Hash Sets" Watch "Hash Tables, Hash Sets" New topic
Author

Hash Tables, Hash Sets

Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Hey everyone,

I've coded in Java for a few semesters now, but not in any of my classes has a hash table or hash set/maps come up. I see people using them in their source code they post on this forum, but i'm not really sure what they do that's better than ways i code. So i was wondering if someone could fill me in on their uses and functionality.


Thanks.
Hunter.


"If the facts don't fit the theory, get new facts" --Albert Einstein
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

You want to make an association between a key and a value? Map Man to the rescue!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

a key to encrypt information?? I'm not really sure what you mean.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Let's say you want to convert state codes to their names.

What's better:
48 more times

or


?

Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

so for something like what you just described would you need two maps?? one for the stateName and one for the keys? or does one map hold the name and the key ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Look up java.util.Map. A single map equates the keys with their values. Some languages refer to these as Dictionaries I believe.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hash Tables, Hash Sets