Significance of inheriting method from superclass instead of default method from implementing interface in java 8

前端 未结 2 734
傲寒
傲寒 2021-01-20 17:05

I came across following paragraph while reading about java 8 default methods from here:

If any class in the hierarchy has a method with same signature

2条回答
  •  难免孤独
    2021-01-20 18:06

    I am not able to see any specific reason behind why this particular behavior is chosen by language designer.

    Method definitions were in Java 1.0, Interface default methods where added in Java 8. Code written for Java 1.0 still needs to work.

    Or its just that interface default method logically bears lesser importance than concrete implementation provided by the super class?

    Effectively they have lesser importance being added after 20+ years of existing code being written.

提交回复
热议问题