Kotlin provides inbuilt datatypes
Kotlin Boolean Type
Boolean type contains
false values, used in conditional expressions
Boolean types also contain nullable object types that can be represented using
Any variable can be assigned directly using boolean values, also called implicit declaration. The compiler infers that the Type is based on the value.
The explicit declaration contains the type of variable declared with a value assigned.
Here is an example
// explicit type declaration and conversion val bool1: Boolean = true // implicit type declaration and conversion val bool2= true val bool3: Boolean = false val bool4: Boolean? = null
Kotlin Characters Types
Each character can be declared using the
Char type in Kotlin language.
Characters are normal alphabets or escape special characters, declared and assigned with single quotes.
val char1: Char = 'e' val char2 = 'f'
Special characters examples
Here is an example of Character type declaration for special characters
val char1: Char = '\t' val char2 = '\r'
String data types
Kotlin String contains a group of characters.
It contains single-line strings enclosed in Double quotes and multi-line strings in triple quotes. You can check more here