Operators
Arithmetic and comparison work as expected, but Kotlin's == and === split content equality from reference equality — the reverse of what Java does by default.
Arithmetic and comparison
The usual arithmetic operators work as expected, and comparisons return a Boolean:
fun main() {
val a = 17
val b = 5
println(a + b)
println(a % b)
println(a > b)
println(a.toDouble() / b)
}
22 2 true 3.4
a / b between two Ints performs integer division and truncates — 17 / 5 is 3, not 3.4. Converting one operand to Double first with .toDouble() forces real division.
Structural equality: == vs ===
This is the operator most likely to trip up someone coming from Java. In Kotlin, == checks structural equality (calls .equals()), while === checks referential equality (are these the exact same object in memory):
fun main() {
val a = "hello"
val b = "hel" + "lo"
println(a == b)
println(a === b)
}
true false
The content is identical, so == is true. But b was built at runtime by concatenation rather than being the same interned string literal, so it's a different object — === is false. This is the opposite default from Java, where plain == on objects compares references and you have to call .equals() explicitly for content.