https://kotlinlang.org logo
#getting-started
Title
# getting-started
s

Sachin Rana

02/02/2021, 2:10 PM
#getting-started Hi All, Does anyone tell me the difference between Kotlin data types and Java data types? As, I am learning about Kotlin data types and I found that in case of Kotlin Data Type we can directly use method like minus, divide etc. directly without using Wrapper Classes as we use in case of Java.
n

nanodeath

02/02/2021, 5:19 PM
you can use minus/divide/operators with any class in Kotlin provided it defines the method (with
operator
keyword) or an extension method, not just data classes
oh, you're talking about data types, not data classes
https://kotlinlang.org/docs/basic-types.html#numbers-representation-on-the-jvm I think this might cover it. basically it boxes automatically, e.g. Int is unboxed when used as a local var, but boxed when used in a Map (e.g. Map<Int, Int>) or as a nullable type (Int?)
2 Views