December 2022
Intermediate to advanced
528 pages
15h 41m
English
This appendix reviews many of the concepts and features discussed in the book, using an older language, Java, and a newer language, Kotlin, instead of Scala. Several examples written earlier in Scala are rewritten in Java or in Kotlin (or both). Code illustrations use Kotlin 1.7 and Java 19 (with some “preview” features enabled).
Java and Kotlin both define methods—both are languages with an object-oriented leaning—and functions (see discussion in Section 9.4). Somewhat confusingly, Kotlin methods are called functions.
Methods and functions are introduced by the keyword fun in Kotlin, whereas Java uses no keyword:
Java
int abs(int x) {
if (x > 0) return x;
else return ...Read now
Unlock full access