开发者

What is the difference between a Hashtable and Properties?

What is the difference between a Has开发者_Python百科htable and Properties?


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 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).


Properties is a subclass of Hashtable, and it is designed for string to string mappings. It also adds the ability to store the mapping into a text file, and read it back.


1.Properties is the subclass of Hashtable. It is more like a map which stores key value pair.

2.In properties both key and value are string

3.In properties we can store the key and value pair in a properties file .

4.Properties class has the ability to load and save the properties file while Hashtable doesn't have this method.

5.Properties files are mostly used to store configuration or localization data. They are used to externalize the data which is configurable to the application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜