Static block vs static method - initializing static fields

后端 未结 2 1378
别跟我提以往
别跟我提以往 2021-02-06 05:58

Out of curiosity, I measured the performance between static block and static method initializer. First, I implemented the above mentioned methods in two separate java classes, l

2条回答
  •  一生所求
    2021-02-06 06:18

    I think that the reason why the static block version is slower than the static method version could be due to the different JIT optimization that they get ...

    See this interesting article for more interesting information : Java Secret: Are static blocks interpreted?

提交回复
热议问题