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. 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 } } Lamda expression is an anonymous function that allows you to pass methods as arguments or simply, a mechanism that helps you remove a lot of boilerplate code. They have no access modifier(private, public or protected), no return type declaration and no name. Lets take a look at this example. (int a, int b) -> {return a > b} In your case, you can do something like below: schedulerFuture = taskScheduler.schedule(new Runnable() { @Override ...