Java 8 pass method as parameter

Solution 1:

It really does not matter; Runnable will do too.

Consumer<Void>,
Supplier<Void>,
Function<Void, Void>

Solution 2:

You can also pass lambda like this:

public void pass() {
    run(()-> System.out.println("Hello world"));
}

public void run(Runnable function) {
    function.run();
}

In this way, you are passing lambda directly as method.