You should always specify an interface. i.e. in this case you should declare your field as follows:
private Map<String, String> map= new HashMap<String, String>();
Thus, everything that uses the map variable will refer to it as a type of map , and not to a HashMap .
This allows you to change the base implementation of your map later without changing any code. You are no longer attached to HashMap
Read this question: What does โinterface programmingโ mean?
Also, I'm not sure if you cast on Set there?
cowls source share