2

For example , why should I use

 Map<String, List<String>> phoneNumbers = new HashMap<String, List<String>>();

instead of

HashMap<String, List<String>> phoneNumbers = new HashMap<String, List<String>>();
  • if phoneNumbers variable's scope is not greater than one method then I would say that usually there's no difference. If this is a field and you decide should your accessor use an interface or a concrete implementation then it really matters. – S. Pauk Mar 26 '15 at 19:14
  • I agree with Sergey .. interfaces allow clean separation at *boundaries*, but are not necessarily applicable at a local (or private/protected) level. – user2864740 Mar 26 '15 at 19:17

0 Answers0