Kotlin’s Improvements
Explore Kotlin's improvements that reduce boilerplate code, including the removal of mandatory semicolons, the absence of the new keyword for object creation, no checked exceptions, and the use of object types over primitives. Understand how these features enhance code clarity, safety, and maintain performance while maintaining full interoperability with Java.
Let’s have a look at the four things we don’t need in Kotlin.
No semicolon necessary
In Kotlin, a semicolon (;) to terminate a statement is not mandatory.
In contrast to Java and other languages, the Kotlin compiler usually recognizes the end of a statement even without an explicit ;, for example, by a line break.
Note: The general rule in Kotlin is not to use semicolons.
However, two marginal exceptions should be noted.
Multiple expressions in the same line
If we want to note several statements in a single line, they are separated with ; ...