Static Typing: Like Java, variables can only be assigned values that match their type.
Non-local jumps: Kotlin allows you to exit a function anywhere
Collection filtering: Allows you to search collections for any data that matches the passed criteria.
Extension functions: Extension functions allow you to extend existing components without writing methods inside them, leading to cleaner code.
Higher-order functions: Kotlin functions are treated as first-class, meaning they can be passed or returned from other functions.
Lazy loading: Decreases loading time by only loading resources it’ll immediately need.
Variables in Kotlin can be either read-only or mutable. The value of read-only variables cannot be changed after they’ve been initially assigned.
It’s best practice to use read-only val variables whenever possible and only use mutable var when you specifically need it. This minimizes the overall complexity of your programs and makes it easier to understand their data flow.
Unlike Java, Kotlin does not have primitive data types. All the following types are objects at runtime but do transpile to the respective Java primitive types in Java bytecode.
Type inference
Allows you to omit types in your code when the compiler can infer it for you. This is also sometimes called smart typing or implicit typing.
If a variable could be declared as two types of differing sizes, it will choose the default: Double for floating-point numbers and Int for integers.
The Kotlin for loop works like a C for each loop rather than Java’s for loop. It accepts a collection, like an array, and completes the same action on each element of the collection.
The while loop executes the body of code repeatedly so long as the listed conditions remain met. Like Java, there are two types of while loop. The standard while loop checks for the condition before the code is executed, and the do-while loop checks after the code is executed.