Beginner 7 min readKotlin 2.0

Kotlin Data Types — Int, String, Boolean and More

Kotlin is statically typed. Every variable has a type — either inferred or explicit. This tutorial covers all the common Kotlin data types with examples.

What You Will Learn

  • All numeric types in Kotlin
  • The Boolean and Char types
  • How String works in Kotlin
  • The Any, Unit, and Nothing types
  • Type conversion between numbers

Overview of Kotlin Data Types

Kotlin has a rich set of built-in types. All types in Kotlin are objects — there are no primitive types visible to developers (though the compiler uses primitives internally for performance).

Common Data Types in Use

kotlin
fun main() {
    val age: Int = 25
    val price: Double = 99.99
    val isActive: Boolean = true
    val grade: Char = 'A'
    val website: String = "KotlinGuide"

    println(age)
    println(price)
    println(isActive)
    println(grade)
    println(website)
}
Output
25 99.99 true A KotlinGuide

Each variable uses an explicit type. In practice, Kotlin infers most types, but writing them explicitly here makes the types easy to see.

Number Types

Kotlin has four integer types and two floating-point types: | Type | Size | Range | |------|------|-------| | Byte | 8-bit | -128 to 127 | | Short | 16-bit | -32,768 to 32,767 | | Int | 32-bit | -2,147,483,648 to 2,147,483,647 | | Long | 64-bit | Very large numbers | | Float | 32-bit | ~7 decimal digits | | Double | 64-bit | ~15 decimal digits | For most everyday numbers, use Int or Double.

Working with Numbers

kotlin
fun main() {
    val count: Int = 1000
    val distance: Long = 9_000_000_000L
    val pi: Double = 3.14159
    val tax: Float = 0.18f

    println(count)
    println(distance)
    println(pi)
    println(tax)
}
Output
1000 9000000000 3.14159 0.18

Underscores in numbers (9_000_000_000) are ignored by the compiler — they just improve readability. L suffix marks a Long literal. f marks a Float.

Beginner Tip: Use Int for whole numbers and Double for decimals unless you have a specific reason to choose another type.

Boolean Type

Boolean has exactly two values: true and false. You use it for conditions, flags, and logic.

Boolean Variables

kotlin
fun main() {
    val isLoggedIn = true
    val hasPermission = false

    println(isLoggedIn)
    println(isLoggedIn && hasPermission)
    println(isLoggedIn || hasPermission)
}
Output
true false true

&& is logical AND (both must be true). || is logical OR (at least one must be true). This is the same as most other languages.

Practice Exercise

Exercisemultiple choice

Which Kotlin type would you use to store the value 3.14?

Quick Quiz

Quick Quiz

What is the default type Kotlin infers for the literal 42?

Frequently Asked Questions

Related Tutorials

Last updated: 2026-05-01Kotlin 2.0

Written by KotlinGuide Editorial Team · Reviewed by KotlinGuide Technical Review