0

Why do we have to use ::class.java for referencing a class while creating Android apps in Kotlin? Despite the fact that the referenced class is in Kotlin.

As an example, if we want to Start an activity from another activity we have to use Intent(this, sampleActivity::class.java) to initiate an Intent.

Note: My query does not refer to the distinction between (:) single colon and (::) double colon, which is addressed Here. I'm curious. Why is 'class.java' used in a Kotlin class?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Faisal Mirza
  • 63
  • 1
  • 12
  • fyi, for Android Kotlin is compiled to Java byte-code just like Java. You might be interested in reading this: https://www.linkedin.com/pulse/process-compiling-android-app-javakotlin-code-ban-markovic/ – Ivo Nov 07 '22 at 12:43

1 Answers1

0

Because its signature accepts Class<?> and Intent itelf is written in Java.

Antoniossss
  • 31,590
  • 6
  • 57
  • 99