I have seen numerous examples for HashMap as well as Hashtable (in java) where they are declared as:
HashMap<KeyType, ValueType> hashmap = new HashMap<KeyType, ValueType>();
or
Hashtable<KeyType, ValueType> hashtable = new Hashtable<KeyType, ValueType>();
However, they are also sometimes declared as:
HashMap hashmap = new HashMap();
or
Hashtable hashtable = new Hashtable();
Same goes for other collections. I always thought that declaration of the type of collection is always a good thing but there are a lot of places where I see them being declared without their types. Can anyone tell which of these methods of declaration is considered proper? Or there is no proper way? What is the difference between these two types of declarations?