Are defaults in JDK 8 a form of multiple inheritance in Java?

前端 未结 8 1783
北荒
北荒 2020-11-30 00:17

A new feature coming in JDK 8 allows you to add to an existing interface while preserving binary compatibility.

The syntax is like

public interface S         


        
8条回答
  •  臣服心动
    2020-11-30 01:03

    I know this is a old post, but as i'm working with this stuff...

    You will have an error from the compiler, telling you that:

     class TimeTravelingStudent inherits unrelated defaults for present() from types Attendance and Timeline reference to present is ambiguous, both method present() in Timeline and method present() in Attendance match.

提交回复
热议问题