Answers for "calling kotlin from java"

1

calling kotlin from java

// Kotlin
class KotlinClass {
  val fixed: String = "base.KotlinClass"
  var mutable: Boolean = false
}

// Java
KotlinClass kotlinClass = new KotlinClass();
String s = kotlinClass.getFixed();     // Uses getter of ‘val’
kotlinClass.setMutable(true);           // Uses setter of ‘var’
boolean b = kotlinClass.getMutable();  // Uses getter of ‘var’
Posted by: Guest on August-11-2021

Code answers related to "calling kotlin from java"

Browse Popular Code Answers by Language