Issue
What is the difference between a Hashtable and Properties?
Solution
Properties
is a very specialized class that's designed to hold configuration and/or resources that are usually stored in some file.
It has several features that Hashtable
doesn't have (and shouldn't have):
- It supports reading and writing its content to a well-defined plain-text format (using
load()
/store()
) - It supports reading and writing its content to a well-defined XML-based format (using
loadFromXML()
/storeToXML()
) - It supports a default mechanism by providing another
Properties
instance at construction time. - It only supports
String
keys and values. While it is technically aMap<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).
Answered By - Joachim Sauer
Answer Checked By - Willingham (JavaFixing Volunteer)