My primary language has been C#, though lately I've been doing more Java development. In C#, I can define a Dictionary like this:
using System.Collections.Generic; ...
Dictionary<string, string> myDict = new Dictionary<string, string>(); However, if I want to create a similar object in Java, I need to do this:
import java.utils.Map; import java.utils.HashMap; ...
Map<String, String> myMap = new HashMap<String, String>(); Why is Java designed so that Map<> is created with a HashMap<> and two different imports are required to use it?
Just curious.
Update
It never even crossed my mind that Map could be an interface. It doesn't follow the convention of prefixing the interface name with an I. I'm surprised that such a convention isn't used there.

HashMap<String, String> myMap = new HashMap<String, String>();and then you only need one import.IDictionaryinterface just that way. The statementusing System.Collections.Genericmakes bothIDictionaryandDictionaryavailable, because they are both in that namespace, so only oneusingis needed. It is similar to the way thatimport java.utils.*does the job for bothMapandHashMap.