Difference between Map and Properties as both have key-value pair.
Properties class allows String key/value pairs to read from or write to a stream. You may have have several application specific parameters to be read at the application startup you can utilize Properties class. HashMap is a collection class which allows to use key/value pairs of objects.
Properties is a subclass of Hashtable. It is used to maintain a list of values in which the key is a string and the value is also a string i.e; it can be used to store and retrieve string type data from the properties file. Properties class can specify other properties list as it's the default.
A Map cannot contain duplicate keys and each key can map to at most one value. Some implementations allow null key and null values like the HashMap and LinkedHashMap, but some do not like the TreeMap. The order of a map depends on the specific implementations.
Standard system properties files and custom properties files are used to configure user preferences and user customization. A Java properties file defines the values of named resources that can specify program options such as database access information, environment settings, and special features and functions.
A map is meant for normal key-value pair usage in code. Properties are typically used for storing and loading configuration values from a file. The underlying implementation of a Properties uses a Map.
See the link below for a quick tutorial on how and when to use Properties.
http://docs.oracle.com/javase/tutorial/essential/environment/properties.html
Properties
is a Facade for Map<String,String>
+ some I/O methods.
Do you need the I/O methods ? use it : don't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With