1

I see this code:

public class MyClass {

Map myMap = new HashMap();

{
    myMap.put("myKey", "my value");
}
//other methods that get values from myMap and it is working fine.
}

What is that block of code called: { } called where we are putting values?

I know this is not a static block because that starts with static { }. And it is definitely not a constructor.

Faraz
  • 6,025
  • 5
  • 31
  • 88

0 Answers0