Sorry to ask that question I've seen that it has been asked a lot but not the way I'm think it.

My goal is to make a retry function that would loop 'n' amount of time to try to run the method I'm passing as parameter.

So in this case I want to run the function "myFunction()" but I know that sometimes the returned value is false and I want to run it until the return value is true.

That's how I would like it to run :

```
public static void main (String [] args){
    boolean did work = retry (myFunction(),5)
    if(didwork){
        System.out.println("I found my stuff");
    } else {
        System.out.println("I didn't found my stuff");
    }
}

public boolean retry (Function function, int loopTry){
    boolean success = false;
    for(int i=0 ; i<loopTry ; i++){
        success = function.run();
        if(success){
            break;
        }
    }
    return success;
}

public boolean myFunction(){
    boolean found = false;
    //do stuff
    if(stuff){
        found = true;
    }
    return found;
}

```

I know that it's not possible (at least in java 7 maybe in 8)

I've seen some answers suggesting to create an object for the specific function etc ... but that's wouldn't make the retry function generic since I would need to remake an object for each method that I would like to retry and that's not what I want.

So I would like to know if there is a "clean" way to do it (even in java 8) or not ?

Thank you