简体   繁体   中英

Kotlin accessing Java class

Why in Kotlin do you need to access they Java class of an object using

MyActivity::class.java

I have been told is something to do with Kotlin's interoperability with JS ... Any thoughts?

Because MyActivity::class returns a KClass<MyActivity> object. This is an extended object that is part of kotlin's expanded reflection capabilities. Since people also need to access the java class for backwards-compatibility it is included as the field java on the KClass object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM