When to use: Java 8+ interface default method, vs. abstract method

后端 未结 15 1781
闹比i
闹比i 2020-11-22 07:01

Java 8 allows for default implementation of methods in interfaces called Default Methods.

I am confused between when would I use that sort of interface default

15条回答
  •  情话喂你
    2020-11-22 07:40

    These two are quite different:

    Default methods are to add external functionality to existing classes without changing their state.

    And abstract classes are a normal type of inheritance, they are normal classes which are intended to be extended.

提交回复
热议问题