spikedude4
New Member
\[quote\] Possible Duplicate:
Type List vs type ArrayList in Java \[/quote\]I was studying Java language, and i saw some codes which when declaring some object, they used a interface as a base type but initialized with a complete class.For instance:\[code\] Map<String,String> map = new HashMap<String,String>();\[/code\]So, what is the reason to use the interface Map instead the class HashMap on object declaration?
Type List vs type ArrayList in Java \[/quote\]I was studying Java language, and i saw some codes which when declaring some object, they used a interface as a base type but initialized with a complete class.For instance:\[code\] Map<String,String> map = new HashMap<String,String>();\[/code\]So, what is the reason to use the interface Map instead the class HashMap on object declaration?