How to write following code in Kotlin for callback implementation

var callback:Callback = object:Callback() {
  override fun getCallback(serverResponse:ServerResponse) {
  }
}

var callback:Callback says that the variable type is a Callback

object:Callback() { } is an anonymous class. It has no name when created, before being assigned to var callback. It's similar to the new Callback() code.

override replaces @Override

fun indicates that it is a function


You can use following code in Kotlin.

var callback:Callback = object:Callback() {
  fun getCallback(serverResponse:ServerResponse) {
  }
}

You can use this link to convert your Java code to kotlin. https://try.kotlinlang.org