Kotlin Data Types

Kotlin Data Types

In Kotlin, everything is an object. While Kotlin often infers data types automatically, understanding the fundamental types is critical for writing robust applications.

Data types are divided into different groups:


1. Numbers

Number types are divided into two groups:

Example

val myNum: Int = 5                // Int
val myDoubleNum: Double = 5.99    // Double

2. Booleans

The Boolean data type can only take the values true or false.

Example

val isKotlinFun: Boolean = true
val isFishTasty: Boolean = false

3. Characters & Strings

val myLetter: Char = 'D'
val myText: String = "Hello"