I am trying to initialize a Map to zeros in a class. I am doing that in this way:
public class A{
private final Map<String,Integer> myMap;
public A(){
this.myMap = new HashMap<String,Integer>() {
{
put("a",0);
put("b",0);
}
};
}
}
My question: Is this a good implementation? Is there anything wrong with this? Or is there any better way to implement this?