I know how to get the runtime of a method from here How do I time a method's execution in Java?
Now I need to get the run time multiple times, so is there a way to make something like
public long exTime(methodToTime())
    long startTime = System.nanoTime();
    methodToTime();
    long endTime = System.nanoTime();
    long duration = (endTime - startTime);
Thanks for your help
edit: to be more specific, my current code is
        long startTime0 = System.nanoTime();
        revealStr("1001*00*10");
        long endTime0 = System.nanoTime();
        long duration0 = (endTime0 - startTime0);
        System.out.println("The runtime is " + endTime0);
          
        System.out.println("10**01*1*0");
        long startTime1 = System.nanoTime();    
        revealStr("10**01*1*0");
        long endTime1 = System.nanoTime();
        long duration1 = (endTime0 - startTime1);
        System.out.println("The runtime is " + endTime1);
        
        System.out.println("0*1*0**0**");
        long startTime2 = System.nanoTime();
        revealStr("0*1*0**0**");
        long endTime2 = System.nanoTime();
        long duration2 = (endTime2 - startTime2);
        System.out.println("The runtime is " + endTime2);
        
        System.out.println("****1*1***");
        long startTime3 = System.nanoTime();
        revealStr("****1*1***");
        long endTime3 = System.nanoTime();
        long duration3 = (endTime3 - startTime3);
        System.out.println("The runtime is " + endTime3);
        
        System.out.println("**********");
        long startTime4 = System.nanoTime();
        revealStr("**********");
        long endTime4 = System.nanoTime();
        long duration4 = (endTime4 - startTime4);
        System.out.println("The runtime is " + endTime0);
which is repetitive and redundant
 
    