Search⌘ K
AI Features

Booleans

Explore Kotlin Booleans to understand true and false values. Learn to perform comparisons with equality and relational operators, plus how to use logical operators to create clear and accurate conditions in your Kotlin programs.

Another basic type is Boolean, which has two possible values: true and false.

Kotlin 1.5
fun main() {
val b1: Boolean = true
println(b1) // true
val b2: Boolean = false
println(b2) // false
}

We use booleans to express yes/no answers, such as:

  • Is the user an admin?

  • Has the user accepted the cookies policy? ...