Why are interface method invocations slower than concrete invocations?

后端 未结 6 986
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 15:24

This is question comes in mind when I finding difference between abstract class and interface. In this post I came to know that interfaces are slow as they required extra in

6条回答
  •  庸人自扰
    2020-11-27 15:42

    Interfaces are slower than abstract class as run time decision of method invocation would add little penalty of time,

    However as JIT comes in picture which will take care of repeated calls of same method hence you may see the performance lag only in first call which is also very minimal,

    Now for Java 8, they almost made abstract class useless by adding default & static function,

提交回复
热议问题