What is an initialization block?

后端 未结 10 2085
青春惊慌失措
青春惊慌失措 2020-11-22 03:42

We can put code in a constructor or a method or an initialization block. What is the use of initialization block? Is it necessary that every java program must have it?

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 03:48

    In addition to what was said in previous answers, blocks can be synchronized .. never felt I need to use it, however,it's there

提交回复
热议问题