I am trying to measure the execution time for several methods. so I was thinking to make a method instead of duplicate same code many times.
Here is my code:
Methods aren't first-class objects in Java, so they can't be passed as parameters. You could use wrap your method call in an annoymous class that extends e.g. the Runnable interface:
private void MeasureExecutionTime(Runnable r) {
r.run();
}
...
MeasureExecutionTime(new Runnable() { public void run() { m(); } });