Last active
January 9, 2017 03:29
-
-
Save bryder/b321152c20ba6d9aa678b18ea35f6708 to your computer and use it in GitHub Desktop.
How to define an interface and use it for a lamba
This file contains hidden or 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
private interface NameOfInterface { | |
public List getAList(Object anArgument); | |
} | |
public void useThePassedMethod(NameOfInterface thingToRun) { | |
Integer thing = 1; | |
List createdList = thingToRun.getAList(thing); | |
} | |
public void callTheThingUsingTheInterface(){ | |
// WIth a static method which meets the specs for a lamdba | |
useThePassedMethod(ClassWithMethodMatchingInterface::methodName); | |
// WIth a lambda | |
useThePassedMethod((anArgument) -> { | |
return new ArrayList(anArgument); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment