How to implement this Java interface in Kotlin?

If a single implementation, as in @zsmb13’s answer, is not enough for you and you need separate implementations for the two methods in Kotlin, then you can add an intermediate interface overriding the method accepting Integer with a nullable parameter: private interface IntermediateA : A { override fun get(i: Int?): Any } Implementing this interface … Read more

Kotlin extension function access Java private field

First, you need to obtain a Field and enable it can be accessible in Kotlin, for example: val field = ABC::class.java.getDeclaredField(“mPrivateField”) field.isAccessible = true Then, you can read the field value as Int by Field#getInt from the instance of the declaring class, for example: val it: ABC = TODO() val value = field.getInt(it) Last, your … Read more

Why do I have to return Unit.INSTANCE when implementing in Java a Kotlin function that returns a Unit?

Unit in Kotlin is mostly equivalent to void in Java, however only when the rules of the JVM allow it. Functional types in Kotlin are represented by interfaces like: public interface Function1<in P1, out R> : Function<R> { /** Invokes the function with the specified argument. */ public operator fun invoke(p1: P1): R } When … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)