fergdev
fergdev

Reputation: 993

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?

Upvotes: 1

Views: 636

Answers (1)

Kiskae
Kiskae

Reputation: 25603

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.

Upvotes: 3

Related Questions