1

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the response. I am now interested in Kotlin's expanded reflection capabilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.