What is the difference between a Hashtable and Properties?

Properties is a very specialized class that’s designed to hold configuration and/or resources that are usually stored in some file.
Properties has several features that Hashtable doesn’t have (and shouldn’t have):

  1. It supports reading and writing its content to a well-defined plain-text format (using load()/store())
  2. It supports reading and writing its content to a well-defined XML-based format (using loadFromXML()/storeToXML())
  3. It supports a default mechanism by providing another Properties instance at construction time.
  4. It only supports String keys and values. While it is technically a Map<Object,Object> actually storing non-String keys or values is strongly discouraged and unsupported.

A Hashtable on the other hand is a general-purpose Map implementation (which is mostly replaced by the HashMap, however).

Tagged , . Bookmark the permalink.

One Response to What is the difference between a Hashtable and Properties?

  1. After research a couple of of the weblog posts on your web site now, and I truly like your means of blogging. I bookmarked it to my bookmark web site list and shall be checking back soon.

Leave a Reply