The basic data types in Kotlin are numbers, characters, Boolean, arrays, and strings. These are described as follows:
- Number: Kotlin provides the following built-in types that represent numbers, similar to Java:
| Type |
Byte |
| Double |
8 |
| Float |
4 |
| Long |
8 |
| Int |
4 |
| Short |
2 |
| Byte |
1 |
Unlike in Java, characters are not numbers in Kotlin.
-
- Byte: Byte is a one-byte or 8-bit type for which values range from -128 to 127
- Short: Short is a two-byte or 16-bit type for which values range from -32768 to 32767
- Int: Int is a four-byte or 32-bit type for which values range from -2^31 to 2^31-1
- Long: Long is an eight-byte or 64-bit type that can have values from -2^63 to 2^63-1
- Double: Double is a double-precision, 8-byte, or 64-bit ...