From the Front matter:
The second edition of Kotlin in Action teaches you the Kotlin programming language and how to use it to build applications running on the Java virtual machine (JVM) and Android.
It starts with the basic features of the language and proceeds to cover the more distinctive aspects of Kotlin, such as its support for building high-level abstractions and domain-specific languages. The book also provides the information you need to integrate Kotlin with existing Java projects and helps you introduce Kotlin into your current working environment.
The book covers Kotlin 2.0.
Who should read this book
Kotlin in Action, Second Edition, is primarily focused on developers with some level of Java experience. Kotlin builds on many concepts and techniques from Java, and the book strives to get you up to speed quickly by using your existing knowledge.
If you’re experienced with other programming languages such as C# or JavaScript, you may need to refer to other sources of information to understand the more intricate aspects of Kotlin’s interaction with the JVM, but you’ll still be able to learn Kotlin using this book.
We focus on the Kotlin language as a whole and not on a specific problem domain, so the book should be equally useful for server-side developers, Android developers, and everyone else who builds projects targeting the JVM.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A thorough, Java-informed tour of Kotlin 2.0 that takes you from everyday syntax to coroutines and DSL design, written for developers who want to write idiomatic Kotlin on the JVM or Android rather than just transliterate Java.
【Book Arc】
- **Opening (~0%–10%)**: Frames Kotlin's value proposition — conciseness, null safety, Java interoperability, and tooling — and sets expectations for readers with Java or similar backgrounds.
- **Early (~10%–30%)**: Core language fundamentals: functions, `val`/`var`, string templates, classes, `if`/`when` as expressions, smart casts, loops, and extension functions/properties for extending existing APIs.
- **Early–Middle (~30%–45%)**: Object-oriented depth — visibility rules, inner vs. nested classes, constructors, interface properties, companion objects, object expressions, and how Kotlin declarations map to Java/bytecode.
- **Middle (~45%–60%)**: Functional programming with lambdas: collection operations (`filter`, `map`, `reduce`, `fold`, `groupBy`, `chunked`, `windowed`), sequences for lazy evaluation, and scope functions like `apply` and `run`.
- **Late (~60%–85%)**: Nullability in depth — safe calls, Elvis operator, `!!`, `let`, lateinit, nullable extensions, type-parameter nullability, and Java platform types.
- **Ending (~85%–100%)**: Advanced abstractions and concurrency — building DSLs, structured concurrency, coroutines, and flows, with guidance on integrating Kotlin into existing Java projects.
【Key Takeaways】
- **Kotlin is designed for smooth Java interoperability** (Early): extension functions, visibility mapping, and bytecode correspondence let you adopt Kotlin incrementally without rewriting existing Java code.
- **Null safety is a first-class language feature, not a library** (Late): safe calls, Elvis, `!!`, `let`, and lateinit give you a graduated toolkit, while platform types expose the boundary where Java's nullability is unknown.
- **Expressions replace statements wherever possible** (Early): `if`, `when`, and `try` return values, reducing boilerplate and intermediate variables compared to Java.
- **Extension functions and properties extend any API without inheritance or wrappers** (Early): they work on JDK, Android, and third-party classes with no runtime overhead.
- **Lambdas plus standard-library collection functions replace manual iteration** (Middle): `filter`/`map`/`fold`/`groupBy`/`chunked`/`windowed` cover most data-shaping needs, and sequences add laziness when intermediate collections would be wasteful.
- **Scope functions like `apply`, `with`, and `run` shape initialization and configuration code** (Middle): `apply` in particular replaces Java-style builders for object setup.
- **Coroutines and structured concurrency are the modern answer to concurrency** (Ending): lightweight coroutines, cancellation propagation, and cold/hot flows let you express concurrent work safely and at scale.
- **Kotlin supports building high-level abstractions and DSLs** (Ending): the language's expressive features are aimed at domain-specific design, not just general application code.
【Reading Tips】
- **Skim the fundamentals if you already know Java**: the early chapters move fast and mostly map familiar concepts; slow down at extension functions, smart casts, and `when` since these change how you write daily code.
- **Deep-read the nullability chapter**: it is the single biggest behavioral difference from Java and the source of most interop friction; pay special attention to platform types.
- **Treat the collections/lambdas chapter as a reference**: bookmark the function families (`associate`, `groupBy`, `chunked`, `windowed`, `zip`, `flatten`, `flatMap`) and return when refactoring loops.
- **Do not skip the coroutines section even if you are not writing concurrent code yet**: structured concurrency shapes how modern Kotlin codebases are organized.
- **Keep the Java-interop material handy during migration**: the visibility and bytecode discussions explain surprises when mixing languages in one project.
【Coverage Limits】
The excerpts cover the book's structure, front matter, and selected sections on fundamentals, extensions, classes, lambdas, collections, nullability, and coroutines, but do not include full chapter text for DSL construction, flows, or Java integration specifics; details there are inferred from section titles and summaries.
Page 15
collections, and arrays 8.1 Primitive and other basic types Representing integers, floating-point numbers, characters, and Booleans with primitive types Usin...
ou’ll continue to learn how to change your habitual ways of thinking and use the full power of Kotlin! Summary The fun keyword is used to declare a function....
rface can contain abstract property declarations. Here’s an example of an interface definition with such a declaration: interface User { val nickname: String...
ith nested collections, the flatten function can help you extract the nested items, while the flatMap function even makes it possible to perform a transforma...
general form of this is visualized in figure 9.7. Figure 9.7 Assignment through square brackets is transformed into a set function call. 9.3.2 Checking wheth...
travariant, it acts only as a consumer, and as we discussed earlier, you don’t know exactly what it can consume. Therefore, you can’t give it anything to con...
syntax, a DSL can express a domain- specific operation much more concisely than an equivalent piece of code in a general-purpose language. Another important...
ny arguments provided for the coroutine context are applied. They may override whatever was previously inherited. The following code snippet and figure 15.4...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Kotlin in Action 2ed 2024 (Sebastian Aigner, Roman Elizarov etc.)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Kotlin in Action 2ed 2024 (Sebastian Aigner, Roman Elizarov etc.)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment