Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Created December 23, 2015 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeaholicguy/51bd0d7ce7be33d1222e to your computer and use it in GitHub Desktop.
Save codeaholicguy/51bd0d7ce7be33d1222e to your computer and use it in GitHub Desktop.
public static class MyFunction implements Callable<Integer> {
private int a;
private int b;
public MyFunction(int a, int b) {
this.a = a;
this.b = b;
}
@Override
public Integer call() throws Exception {
return this.a + this.b;
}
}
public static void main(String... args) throws Exception {
Map<String, Callable> superhero = new HashMap<>();
superhero.put("doHero", new MyFunction(3, 5));
System.out.println(superhero.get("doHero").call());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment