Junior — Middle
What existing data type categories do you know in Kotlin?
sobes.tech AI
Answer from AI
In Kotlin, the following main categories of data types exist:
- Primitive types (numbers, characters, boolean values): Int, Long, Double, Float, Char, Boolean.
- Strings: String — an immutable type for text.
- Collections:
- Mutable (modifiable): MutableList, MutableSet, MutableMap.
- Read-only (for reading only): List, Set, Map.
- Nullable types: any type can be declared with
?, for example,String?, to allow null values. - User-defined classes and objects: classes, data class, sealed class, etc.
- Functional types: function types, for example,
(Int, Int) -> Int.
Kotlin also supports type extensions and wrapper types, making the type system flexible and powerful.