All the solutions are really hacky, but the array is a "standard" textbook that can handle it, since even the pre-peaks were typical.
Another option in this situation is to create a private class as follows:
private class Searcher implements SearchCallback { private boolean found; @Override public void onFound(Object o) { found = true; } public boolean search() { OuterClass.this.search(this); return found; } }
And then use it like this:
boolean found = new Searcher().search();
Edit: if I understand Tom's comment correctly, he offers this as an alternative
public void foo() { //This is the method that enclosed the code in your question new SearchCallBack() { private boolean found; @Override public void onFound(Object o) { found = true; } { //The code that was before this in your method search(this); //The code that was after this in your method } }; }
I think these are more hacks, and I would really find such code unusual, but it is definitely worth knowing that this is an option.
source share