Skip to content

Instantly share code, notes, and snippets.

@fatbigbright
Last active September 29, 2017 06:08
Show Gist options
  • Save fatbigbright/d8608589e7b75b171537d12a181f90d2 to your computer and use it in GitHub Desktop.
Save fatbigbright/d8608589e7b75b171537d12a181f90d2 to your computer and use it in GitHub Desktop.
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