The java.util.Properties
class is meant to represent a map where the keys and values are both Strings. This is because Properties
objects are used
The reason: Liskov substitution principle and backwards compatibility. Properties
extends Hashtable
and thus must accept all messages that Hashtable
would accept - and that means accepting put(Object, Object)
. And it has to extend plain Hashtable
instead of Hashtable
because Generics were implemented in the downwards-compatibe way via type erasure, so once the compiler has done its thing, there are no generics.