Shape Shape Group point Group chapter-list Shape Shape Copy 12 Shape Shape Copy 3 Shape Group Shape dropdown editor editor Combined Shape grid Shape Copy 4 Shape Copy 7 Shape language language Shape megaphone paperback Shape platform noun_419259-2 copy play-icon BS-Question-Rounded-Circle quotes noun_610406 stacked-books-1 stacked-books-2 Shape Copy 5 Combined Shape Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group

Kotlin Apprentice

  • Platform Android4.4+
  • Language Kotlin1.2
  • Editor IntelliJIDEA

Learn programming with Kotlin!

The Kotlin Apprentice is a book designed for complete beginners to Kotlin, a modern language used for Android development.

Developer Guide


For beginner iOS developers

This book is for complete beginners to Kotlin. No prior programming experience is necessary!

This is a book for complete beginners to the new, modern Kotlin language.

Everything in the book takes place in a clean, modern development environment, which means you can focus on the core features of programming in the Kotlin language, without getting bogged down in the many details of building apps.

This is a sister book to the Android Apprentice the Android Apprentice focuses on making apps for Android, while the Kotlin Apprentice focuses on the Kotlin language fundamentals.

We also recommend

Kotlin Apprentice


Your Kotlin Development Environment

Get a quick-start introduction to Kotlin and how to use Intellij IDEA to work with the projects through this book.


Expressions, Variables & Constants

This is it, your whirlwind introduction to the world of programming! You’ll begin with an overview of computers and programming, and then spend your time working with code comments, arithmetic operations, constants and variables.


Types & Operations

You’ll learn about handling different types, including strings which allow you to represent text. You’ll learn about converting between types and you’ll also be introduced to type inference which makes your life as a programmer a lot simpler.


Basic Control Flow

You’ll learn how to make decisions and repeat tasks in your programs by using syntax to control the flow. You’ll also learn about Booleans, which represent true and false values, and how you can use these to compare data.


Advanced Control Flow

Continuing the theme of code not running in a straight line, you’ll learn about another loop known as the `for` loop. You’ll also learn about when expressions which are particularly powerful in Kotlin.



Functions are the basic building blocks you use to structure your code in Kotlin. You’ll learn how to define functions to group your code into reusable units.



Many programming languages suffer from the "billion dollar mistake" of null values. You'll learn about how Kotlin protects you from the dreaded null pointer exception.


Arrays & Lists

Arrays and lists are the most common collection types you’ll run into in Kotlin. They both are typed like regular variables and constants, and store multiple values in a single data structure. See how to iterate through arrays and lists and how to modify their contents.


Maps & Sets

Maps are useful when you want to look up values by means of an identifier. For example, the table of contents of this book maps chapter names to their page numbers, making it easy to skip to the chapter you want to read. With an array, you can only fetch a value by its index, which has to be an integer, and all indexes have to be sequential. In a map, the keys can be of any type and are generally in no particular order. You'll also learn about Sets, which let you store unique values in a collection.



A previous chapter taught you about functions. But Kotlin has another construct you can use to break up code into reusable chunks: lambdas. These have many uses, and become particularly useful when dealing with collections such as a list or map.



In this chapter, you’ll get acquainted with classes, which are are named types. Classes are one of the cornerstones of object-oriented programming, a style of programming where the types have both data and behavior. In classes, data takes the form of properties and behavior is implemented using functions called methods.



Kotlin has a special keyword object that makes it easy to follow the Singleton pattern in your projects, and that is also used to create properties specific to a class and not its instances. You also use the keyword to create anonymouse classes.



In this chapter, you’ll learn more about Kotlin properties, along with some tricks to deal with properties, how to monitor changes in a property’s value and how to delay initialization of a property.



Methods are merely functions that reside in a class. In this chapter, you’ll take a closer look at methods and see how to add methods onto classes that were created by someone else.



Classes are used when you want to create types that contain both state and behavior. When you need a type that allows primarily the specification of behavior, you're better off using an interface. See how to create and use interfaces.


Advanced Classes

Having seen the basics of creating classes, in this chapter you'll see the more advanced aspects of object-oriented programing, including inheritance and limiting member visibility.


Enum Classes

Enumerations are useful when you have a quantity that can take on a finite set of discrete values. See how to define and use enum classes and see some examples of working with enum classes and when expressions.



At some point you will need to ability to create abstractions that go beyond what's available in regular classes and functions. You'll learn how to use generics to super-power your classes and functions.


Kotlin/Java Interoperability

Kotlin was designed from the start to be 100% compatible with Java and the Java ecosystem. See how to work with Kotlin and Java together in a single project and how to call back and forth between the two.



No software is immune to error conditions. See how to use exceptions in Kotlin to provide some control over when and how errors are handled.


Functional Programming

Kotlin goes beyond just being an object-oriented programming language, and provides many of the constructs found in the domain of functional programming. See how to treat functions as first-class citizens by learning how to use functions as parameters and return values from other functions.


Conventions & Operator Overloading

You'll learn the concept of conventions and see how to use conventions to implement operator overloading and write more concise but still readable code.


Kotlin Coroutines

Kotlin coroutines allow you to simplify your asynchrounous code and make it much more readable. You'll learn the difference between threads and coroutines and see examples of coroutines in use.


Scripting with Kotlin

Kotlin is not just useful on Android or the JVM, but also can be used for scripting at the command line. See how to use Kotlin as a scripting language.

Meet the authors

Joe Howard Android Team Lead
Dick Lucas Android Team
Irina Galata Android Team
Ellen Shapiro Android Team

Get the Kotlin Apprentice

Learn programming with Kotlin! The Kotlin Apprentice is a book designed for complete beginners to Kotlin.