September 2023
Intermediate to advanced
470 pages
11h 12m
English
In my opinion, the single main advantage of Kotlin over Java is the powerful type system. We’ll cover some of its features here, but for a general overview there is a nice blog post by Nat Pryce.[84]
The first thing a Java programmer usually notices when looking at Kotlin code for the first time is that there are a number of question marks interspersed in the code. They are used to specify that something can be nullable.
A nullable type is a type created by the union of a nonnullable type with the null. It has a question mark ? appended after the type name:
| | val maybeAString: String? = null |
| | val definitelyAString: String = null //doesn't compile! |
There are two rules with nullable types: ...
Read now
Unlock full access