Java 8 default methods vs. non-abstract methods in abstract classes

前端 未结 5 1085
一个人的身影
一个人的身影 2020-12-16 15:41

Java 8 interface default methods vs. non-abstract methods in abstract classes - are there any differences between the two (besides the differences of iface - class, visibili

5条回答
  •  清歌不尽
    2020-12-16 16:03

    The main differences are: Java 8 default methods of interfaces are public, while non-abstract (concrete) methods of abstract classes can be defined as public, protected or private. Lambda expressions got introduced in Java 8, to use lambda features we need default methods(to preserve backward compatibility), non-abstract methods of abstract classes can not serve the purpose.

提交回复
热议问题