Skip to content

mtumilowicz/java11-invoking-default-method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

java11-invoking-default-method

Explicitly invoking default method from enclosing interface.

preface

A class (or an interface) can invoke a default method of an interface that is explicitly mentioned in the class's implements clause (or the interface's extends clause) by using the same syntax <InterfaceName>.super.<methodName>

project description

We provide examples with tests for mentioned above features.

  • class
    public class CustomClass implements Interface1, Interface2 {
        public String get() {
            return "CustomClass";
        }
    
        String getI1() {
            return Interface1.super.get();
        }
    
        String getI2() {
            return Interface2.super.get();
        }
    }
    
  • interfaces
    interface Interface1 {
        default String get() {
            return "Interface1";
        }
    }
    interface Interface2 {
        default String get() {
            return "Interface2";
        }
    }
    
  • tests in CustomClassTest

About

Explicitly invoking default method from enclosing interface.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages