When we start new activity into kotlin why we put .java in intent instead of .kt

后端 未结 1 1710
悲&欢浪女
悲&欢浪女 2020-12-11 22:53

As per kotlin doc we start new activity with following syntax

startActivity(Intent(this@MainActivity, NextActivity::class.java))

its kotlin

相关标签:
1条回答
  • 2020-12-11 23:18

    Because NextActivity::class gives you KClass<NextActivity>, and KClass has a method/extension property called java which gives you the java.lang.Class<NextActivity> for the given class.

    You can even check out the source-code for that java property.

    0 讨论(0)
提交回复
热议问题