如何在Java中调用将回调作为参数的函数

如何在Java中调用将回调作为参数的函数,java,android,kotlin,Java,Android,Kotlin,我正在尝试在我的android应用程序中实现,我必须调用initialize方法 他们在文档中这样称呼它: // Initialize the ReachFive client client.initialize({ providers -> // On success, do something with the retrieved list of providers registered for this ReachFive client

我正在尝试在我的android应用程序中实现,我必须调用initialize方法

他们在文档中这样称呼它:

    // Initialize the ReachFive client
    client.initialize({ providers ->
        // On success, do something with the retrieved list of providers registered for this ReachFive client
        // ...
    }, {
        // On failure, log the error message returned by the ReachFive client
        Log.d("Reach5_MainActivity", "ReachFive init ${it.message}")
    })
但是这个代码示例在Kotlin中,我不知道如何在java中调用
initialize
方法

编辑:这是SDK代码中的
初始化
函数:

fun initialize(
    success: Success<List<Provider>> = {},
    failure: Failure<ReachFiveError> = {}
): ReachFive {
    reachFiveApi
        .clientConfig(mapOf("client_id" to sdkConfig.clientId))
        .enqueue(
            ReachFiveApiCallback<ClientConfigResponse>(
                success = { clientConfig ->
                    scope = clientConfig.scope.split(" ").toSet()
                    providersConfigs(success, failure)
                },
                failure = failure
            )
        )

    return this
}
fun初始化(
success:success={},
失败:失败={}
):ReachFive{
reachFiveApi
.clientConfig(将“客户端id”映射到sdkConfig.clientId))
.排队(
到达顶端返回(
success={clientConfig->
scope=clientConfig.scope.split(“”.toSet()
提供者配置(成功、失败)
},
失败=失败
)
)
还这个
}
试试这个(把函数的实现/逻辑放在点上,而不是点上)

请注意,第一个方法应返回
成功
的实例,第二个lambda应返回
失败

试试这个(把函数的实现/逻辑放在这里,而不是点上)


请注意,第一个方法应返回
成功
的实例,第二个lambda应返回
失败

每个lambda都是功能接口。每个lambda都是功能接口。就这样!谢谢:)@R3J3CT3D不客气!请注意,上面的方法只是将函数接口的对象传递给初始化方法。在我的回答中,我匿名声明了它们,而它们也可以显式声明。你应该多读一读,就这样!谢谢:)@R3J3CT3D不客气!请注意,上面的方法只是将函数接口的对象传递给初始化方法。在我的回答中,我匿名声明了它们,而它们也可以显式声明。你应该多读一些
client.initialize((providers) -> {...}, (error) -> {...});