Elements of Kotlin


The programming language for the first generation of Android app development was Java.

The programming language that will dominate the second generation of Android app development will be Kotlin.

Kotlin is a powerful language, designed to be concise yet expressive, both for application code and for libraries. However, some of that comes at a cost, as Kotlin has a lot more keywords and specialty features than does Java. A lot of that complexity is only needed by intermediate to advanced Kotlin developers, though.

This introductory book to Kotlin focuses on helping existing programmers get up to speed on reading and writing Kotlin code. Particular emphasis is placed on the sorts of syntax and language capabilities that most Kotlin developers will need, with light coverage of the advanced capabilities that allow library developers to create easy-to-use APIs.

Most of the sample code from the book is available in the Klassbook, so you can try running it in your Web browser.

This book is published in PDF, EPUB, and MOBI/Kindle formats, for use in your favorite digital book reader. Or, read directly in your Web browser. Note that the HTML edition will be taken down at the end of 2025, as this book will be rather old at that point. However, the downloadable forms (PDF, etc.) will still be available.

Read Here

Details

  • Published on: 2021-04-19
  • 412 pages
  • Errata

The Table of Contents

Each bullet shown below represents a chapter. Use the search field in the nav bar to search all of the CommonsWare books to see what they hold!

  • Introducing Kotlin
  • A Few “Hello, World!” Examples
  • Basic Types and Expressions
  • Variables… Whether They Vary or Not
  • Functions
  • Collections and Lambdas
  • If, When, and While
  • Basic Classes
  • Comments and Documentation
  • Properties
  • Visibility and Scope
  • Abstract Classes and Interfaces
  • Data Class
  • The object Keyword
  • Nested Objects and Classes
  • Enums and Sealed Classes
  • Generics
  • Exceptions
  • Annotations
  • Nullability
  • Scope Functions
  • Functional Programming
  • Extension Functions
  • Java Interoperability
  • Changes in Newer Kotlin Versions
  • Custom Accessors
  • Extension Properties
  • Escaping Keywords
  • Escaped Method Names
  • Property Delegates
  • Class Delegation
  • Constants
  • Abstract Properties
  • Covariance in Generics
  • Contravariance in Generics
  • Anonymous Functions
  • Local Functions
  • Local Types
  • Inline Functions
  • Inline Classes
  • Reified Type Parameters
  • noinline and crossinline
  • Receivers in Function Types
  • Renamed Imports
  • Operator Overloading
  • Infix Functions
  • Destructuring Declarations
  • Labeled Returns
  • Nothing
  • Types of Keywords