Hello sekitaka.
I was wondering how to write class name.class
in java in Kotlin, so make a note of it.
You can use a class object by using :: class.java
as shown below.
val jclass = String::class.java
val kclass = String::class.java.kotlin
println(jclass) // class java.lang.String
println(kclass) // class kotlin.String
Added based on the comment received by @meeniex. You can refer to it from the instance as follows.
val jclass = s.javaClass
val kclass = s.javaClass.kotlin
println(jclass) // class java.lang.String
println(kclass) // class kotlin.String
Recommended Posts