Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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