Last active
September 29, 2017 06:08
-
-
Save fatbigbright/d8608589e7b75b171537d12a181f90d2 to your computer and use it in GitHub Desktop.
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
import java.io.*; | |
public class HelloWorld { | |
static class Foo { | |
public int x; | |
public Foo(int in) | |
{ | |
x = in; | |
} | |
} | |
@FunctionalInterface | |
interface Accumulator { | |
int accumulate(int input); | |
} | |
@FunctionalInterface | |
interface Processor { | |
void process(Foo input); | |
} | |
public static void main(String []args) { | |
// | |
Accumulator a = input -> input + 1; | |
System.out.print(a.accumulate(5)); | |
// | |
Foo foo = new Foo(5); | |
Processor p = f -> f.x += 1; | |
p.process(foo); | |
System.out.print(foo.x); | |
// | |
a.accumulate(foo.x); | |
System.out.print(foo.x); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment