Kotlin Types

Basic Types

In Kotlin, almost everything is an object, including numbers, characters, and boolean types. Even though numbers may be represented using primitive types at the lower level, they can still be used like ordinary classes.

Tips: Hold down Ctrl and click the left mouse button to view Kotlin's source code in IntelliJ IDEA.

Numbers

Numbers include integer types and floating-point types.

Integer Types

Kotlin provides a set of built-in types to represent numbers. For integers, there are four different-sized types, each with its own range of values.

TypeSize (bits)Minimum ValueMaximum Value
Byte8-128127
Short16-3276832767
Int32-2,147,483,6482,147,483,647
Long64-9,223,372,036,854,775,8089,223,372,036,854,775,807

When you define a variable without specifying its type, Kotlin's compiler automatically infers the type.

Float Types

Boolean

Char

String

Arrays

PreviousHomeNext