The instance initialiser is just to make things easier in this case. I don't see the need for an extra anonymous class just to initialize. And it won't work if the class being created is final.
Here is how you can create an immutable map using a static initialiser too:
public class Test {
private static final Map<Integer, String> myMap;
static {
Map<Integer, String> aMap = ....;
aMap.put(1, "one");
aMap.put(2, "two");
myMap = Collections.unmodifiableMap(aMap);
}
}
If you want to learn Java, I recommend this Java Online Course by Intellipaat.