Search code examples
javalambdajava-8java-7java-9

Meaning of lambda () -> { } in Java


I am looking at the following Stack Overflow answer: How to change Spring's @Scheduled fixedDelay at runtime

And in the code there is the following line:

schedulerFuture = taskScheduler.schedule(() -> { }, this);

I would like to know what the lambda () -> {} means in that code. I need to write it without using lambdas.


Solution

  • Its a Runnable with an empty run definition. The anonymous class representation of this would be:

    new Runnable() {
         @Override public void run() {
              // could have done something here
         }
    }