Data TypeDescriptionSize (bits)Range/ValuesExample
Numeric
ByteSigned integer8-128 to 12710, -5
ShortSigned integer16-32768 to 3276710000, -2000
IntSigned integer32-2,147,483,648 to 2,147,483,647123456789, -1000000
LongSigned integer64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,8071000000000000, -5000000000
FloatFloating-point32±1.40129846432481707e-45 to ±3.40282346638528860e+383.14f, -2.5f
DoubleFloating-point64±4.94065645841246544e-324 to ±1.79769313486231570e+3083.14159, -2.71828
Text
CharSingle character16Any valid Unicode character'a', '?', '한'
StringSequence of charactersVariable"Hello", "Kotlin"
Boolean
BooleanBoolean valuetrue, false
Other
ArrayFixed-size collection of elements of the same typeVariablearrayOf(1, 2, 3), arrayOf("a", "b")
  • Size: The size of String and Array types is dynamic and depends on the content.
  • Boolean size: The exact size of a Boolean isn't precisely defined in the language specification and can vary depending on the JVM implementation and platform. It's often optimized to be efficient.
  • Character size: Kotlin uses UTF-16 encoding for characters, so each Char takes 16 bits (2 bytes).

This table gives you a good overview of Kotlin's basic data types. Remember that efficient memory management is often handled by the Kotlin compiler and the JVM, so you usually don't need to worry about the exact size of these types in your everyday coding.