Does Kotlin have primitive types?

后端 未结 3 519
醉话见心
醉话见心 2021-02-08 10:30

Does Kotlin have primitive types?. When I declare the variable: val myAge: Int = 18 then the myAge variable stores the actual values is 18

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 10:48

    Short answer - yes and depends on the declaration.

    val myAge: Int = 18           // this is primitive
    val myAge2: Int? = 18         // this is not
    

    There's a very informative video about that https://www.youtube.com/watch?v=Ta5wBJsC39s

提交回复
热议问题