I am new to Java and trying to pass a function as an argument that gets called when a certain event occurs. I came across Callable and found a few answers for similar problems but not this exactly.
Currently, my code is doing this
doSomething(new Callable<Void>() {
public Void call() {
System.out.println("callback called! ");
return null;
}
});
But I want this :
doSomething(new Callable<Void>() {
public Void call(String foo) { // Want this function to accept parameters
System.out.println("callback called with string " + foo);
return null;
}
});