有人可以告诉我如何在Kotlin中创建界面对象吗?

时间:2019-12-06 20:51:35

标签: kotlin

我必须对Kotlin中的接口做一个介绍。我的主题之一是“创建对象的界面”您如何做到的?

1 个答案:

答案 0 :(得分:0)

使用object表达式

val instanceOfYourInterface = object : YourInterfaceHere {

    override fun methodOfYourInterfaceHere() { /*...*/ }

}

docs中阅读更多内容