@JvmOverloads JAVA调用Kotlin方法

class AnimalDefault @JvmOverloads constructor(context: Context, name:String, sex:Int = 0) {
 init {
 var sexName:String = if(sex==0) "0" else "1"
 context.toast("名字${name}性别${sexName}")
 }
}


//调动
@JvmOverloads
AnimalDefault animal = new AnimalDefault(this, animalName);

你可能感兴趣的:(@JvmOverloads JAVA调用Kotlin方法)