简体   繁体   中英

What is the difference between a Hashtable and Properties?

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.

It has several features that Hashtable doesn't have (and shouldn't have):

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM