val a = 10
val b = 3
println(a + b) // 13
println(a - b) // 7
println(a * b) // 30
println(a / b) // 3
println(a % b) // 1var x = 5
x += 2 // x = 7
x -= 1 // x = 6
x *= 3 // x = 18
x /= 2 // x = 9
x %= 4 // x = 1val x = 5
val y = 8
println(x == y) // false
println(x != y) // true
println(x > y) // false
println(x < y) // true
println(x >= 5) // true
println(y <= 8) // trueLogical operators are used with boolean values:
val age = 20
val hasID = true
val canEnter = (age >= 18) && hasID
val isChild = age < 13 || !hasID
println(canEnter) // true
println(isChild) // falseUse + to concatenate strings:
Kotlin provides two different operators to compare values:
== checks structural equality — whether two values have the same content. Internally, it calls the equals() method.=== checks referential identity — whether two references point to the exact same object in memory.Here’s how they behave in practice:
Ask the AI if you need help understanding or want to dive deeper in any topic