Created
September 19, 2022 16:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SuperClass { | |
public String doWork(String input) { | |
return "super: " + input; | |
} | |
} | |
public class SubClass extends SuperClass { | |
@Override | |
public String doWork(String input){ | |
return "this: " + input; | |
} | |
public void superAndThis(String input) { | |
// ACCESSING THIS INSTANCE | |
Function<String, String> thisWorker = this::doWork; | |
var thisResult = thisWorker.apply(input); | |
// ACCESSING THE SUPER IMPLEMENTATION | |
Function<String, String> superWorker = Subclass.super::doWork; | |
var superResult = superWorker.apply(Subclass.super::doWork); | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment