📜  从 java 调用 kotlin - Kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:33.428000             🧑  作者: Mango

代码示例1
// 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’