How to convert this code to java8 lambda

后端 未结 3 1764
暖寄归人
暖寄归人 2021-01-13 15:04

I\'ve just started working with Java 8 and I\'m struggling with this code snippet:

paramsValues[idx++] = new ReplyMessage() {
    @Override         


        
3条回答
  •  不知归路
    2021-01-13 15:15

    paramValues[idx++] = reply -> message.reply(reply);
    

    Or

    paramValues[idx++] = reply -> {
        return message.reply(reply);
    }
    

    It will work as long as ReplyMessage is functional interface and paramValues is of type ReplyMessage.

提交回复
热议问题