Kotlin

Kotlin Data Types1 min read

Following Kotlin program example to show data types Numbers, Characters and boolean.

Byte : The Byte data type can have values from -128 to 127 (8-bit signed two’s complement integer).




Short : The Short data type can have values from -32768 to 32767 (16-bit signed two’s complement integer).

Int : The Int data type can have values from -2^31 to 2^31 – 1 (32 bit signed 2’s complement integer).

Long : The Long data type can have values from -2^63 to 2^63 – 1 (64 bit signed 2’s complement integer).

Double : The Double type is a double-precision 64-bit floating point. If you assign a floating point value to a variable and do not declare the data type explicitly, it is inferred as Double data type variable by the compiler.

Float : The Float data type is a single-precision 32-bit floating point.

Char : Characters are represented by the type Char. You need to use single quotes ‘ ‘ to denote a character. For example : ‘C’,’K’

Boolean : As like Java Boolean data type has two possible values, either true or false.

Kotlin Code:

Output:

Leave a Comment