Algus

Built-in Types

A Type describes the data that is held by a variable or a constant and tells the compiler how type checking will be handled.

TypeDescriptionTypeDescription
String“Text”CharCharacter
Booleantrue | falseIntByte | Short | Int | Long
Float | DoubleDecimal NumberListCollection of elements
SetCollection of unique elementsMapCollection of key-value pairs

Java types

In Java, there are two kinds of types: reference types and primitive types.

The name of reference types in Java begins with a Capital letter to indicate that they are backed by a source definition. E.g. Integer.

The names of Java primitive types start with a lowercase letter. E.g. int.

All primitives in Java have a corresponding reference type, but not all reference types have a corresponding primitive type.

One reason for choosing a reference type is that there are certain features of the Java language that are only available when using reference types. Generics, for example, don’t work with primitives. Reference types can also work with the object-oriented features of Java than its primitive values.

On the other hand, primitives offer better performance and some other perks.

Unlike Java, Kotlin provides only one kind of type: reference types.

Kotlin made this design decision for several reasons: