This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The main reason to do this is to decouple your code from a specific implementation of the interface. By writing your code like this:
then the rest of your code only knows that data is a Map<String, Object>, which is good, because it you can now easily change to a different implementation of interface Map if necessary. You'd only need to change that one line of code, for example to:
For the rest of your program, nothing changes - data is still a Map<String, Object>.
If you would have written:
then changing it would have been much harder, because the rest of your code might have used methods that are specific to HashMap.