Tutorial by Examples

In Kotlin, variable declarations look a bit different than Java's: val i : Int = 42 They start with either val or var, making the declaration final ("value") or variable. The type is noted after the name, separated by a : Thanks to Kotlin's type inference the explicit typ...
Kotlin does not need ; to end statements Kotlin is null-safe Kotlin is 100% Java interoperable Kotlin has no primitives (but optimizes their object counterparts for the JVM, if possible) Kotlin classes have properties, not fields Kotlin offers data classes with auto-generated equals/hashCode ...
Kotlin uses == for equality (that is, calls equals internally) and === for referential identity. JavaKotlina.equals(b);a == ba == b;a === ba != b;a !== b See: https://kotlinlang.org/docs/reference/equality.html
In Kotlin, if, try and others are expressions (so they do return a value) rather than (void) statements. So, for example, Kotlin does not have Java's ternary Elvis Operator, but you can write something like this: val i = if (someBoolean) 33 else 42 Even more unfamiliar, but equally expressive, ...

Page 1 of 1