Statement lambda can be replaced with expression lambda

Your statement lambda

param -> { return expression; }

can be changed to an expression lambda:

param -> expression

Simple, isn't it? Note, that the curly brackets and the semicolon need to be removed.


Sometimes I found useful to leave the braces where they are if the block of code is long enough (I think it improves readability)

In Android Studio you can locally disable the warning using //noinspection CodeBlock2Expr at the start of the method like in the example below

//noinspection CodeBlock2Expr
button.setOnClickListener((View v) -> {
        //a long single method call...
});