Results 1 to 7 of 7

Thread: Hashtable

  1. #1
    angelicsign is offline Member
    Join Date
    Dec 2008
    Posts
    25
    Rep Power
    0

    Default Hashtable

    I really do not understand what is hashtable and iterator even after i read some of the explanation and coding.
    without it,i still can write and compile my program.
    actually when we have to use it and how to use it?:confused:
    can someone point me to the write way?:)

  2. #2
    Jasonre is offline Member
    Join Date
    Jan 2009
    Posts
    40
    Rep Power
    0

    Default

    Hashtable as in HashMap?

  3. #3
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

    Default

    hashtable
    a kind of mapping
    maps keys to values
    keys and values seem cant be null

    detail in
    Hash table - Wikipedia, the free encyclopedia

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Just curious why you are using a HashTable and not the more recent and possibly robust HashMap?

  5. #5
    Jasonre is offline Member
    Join Date
    Jan 2009
    Posts
    40
    Rep Power
    0

    Default

    That was actually the point i was going to make, HashMap over HashTable.
    HashMap is basically a 1 to 1 function. Key -> Value. The key could be anything (String), not just a number like an array. and that key is pointing at a value. so when you say HashMap.get("key1") it returns value1. and value1 can be any type of object, but for simplicity we can say a String "value1". and when you want to store a new value in a key into the HashMap, HashMap.put(key2, "key2"); and if you want the value in that instance you do a get on the key, key2. any questions still?

  6. #6
    neilcoffey is offline Senior Member
    Join Date
    Nov 2008
    Posts
    286
    Rep Power
    7

    Default

    Essentially, a hash map (and maps in general) are used in cases where you want to know or remember "for X, what is the Y"?

    In case it's useful, I've written various pages about hash maps:

    - a basic guide to using hash maps (including an outline of when to use them)
    - how hashing works
    - how hash functions work: a look at the String hash function works and its implications for other hash functions.

  7. #7
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

Similar Threads

  1. Multidimensional hashtable?
    By jklsemicolon in forum New To Java
    Replies: 6
    Last Post: 08-17-2008, 06:23 AM
  2. how can we get the element of by using the hashtable
    By raj reddy in forum Web Frameworks
    Replies: 1
    Last Post: 05-06-2008, 02:45 PM
  3. Hashtable example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-15-2008, 09:43 AM
  4. Hashtable-put method
    By new_1 in forum New To Java
    Replies: 1
    Last Post: 12-23-2007, 08:07 PM
  5. HashTable problem
    By jhetfield18 in forum New To Java
    Replies: 2
    Last Post: 12-16-2007, 11:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •