Skip to content
Advertisement

Kotlin to Java migration

I am unable to translate(from Kotlin to Java) or understand this statement service.connectionListener = { addConnection(it) } which is found in the inner class of the following file:

JavaScript

I was unable to translate the above statement (commented out):

JavaScript

Advertisement

Answer

This code in Kotlin:

JavaScript

Corresponds to this code in Java:

JavaScript

It is assumed that Service class is written in Kotlin and looks like this:

JavaScript

Update:

If you want to rewrite Service class too, your code will be:

JavaScript

Service class in Java:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement