• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hashtable

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what Hashtable class is for in java?
I look in API, but I still have confusion
Thanks,
Angela
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of a hashtable as a special kind of database table with two columns. When you create the table, you don't have to specify the data types of these columns. The first column is the ID or Key column, the second is the actual object ( or rest of the record, if you will ).
Just like you can do a Select * where ID = XX in an Relational database table, you can do a get() on a hastable. You pass the ID value to the get method. It returns an Object which you can then cast to the real type of the object.
You can look at the methods such as
values (), keyset(), entryset() and put() roughly along the following lines.
values() - return the second column from all the rows of the table
keyset() return the ID column from all the rows of the table
entryset() return both the columns from all the rows
put() insert a record with the given values for the two columns and so on.
Remember this is just an anology to help you understand how hashtable can be used.
HTH
 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Shivaji,
 
This is my favorite show. And this is my favorite tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic