0%

Book Description

Get started with Kotlin programming for building real world applications

Key Features

  • Start programming with Kotlin
  • Explore Kotlin language syntax, standard libraries and Java Interoperability
  • Builds an example application with what you learn

Book Description

Kotlin is a general purpose, object-oriented language that primarily targets the JVM and Android. Intended as a better alternative to Java, its main goals are high interoperability with Java and increased developer productivity. Kotlin is still a new language and this book will help you to learn the core Kotlin features and get you ready for developing applications with Kotlin.

This book covers Kotlin features in detail and explains them with practical code examples.You will learn how to set up the environment and take your frst steps with Kotlin and its syntax. We will cover the basics of the language, including functions, variables, and basic data types. With the basics covered, the next chapters show how functions are first-class citizens in Kotlin and deal with the object-oriented side of Kotlin.

You will move on to more advanced features of Kotlin. You will explore Kotlin's Standard Library and learn how to work with the Collections API. The book finishes by putting Kotlin in to practice, showing how to build a desktop app.

By the end of this book, you will be confident enough to use Kotlin for your next project.

What you will learn

  • Programming in Kotlin language syntax, basic types, control ?ow, classes, and OOP
  • Writing functions and functional programming in Kotlin
  • Defning and importing from packages in Kotlin
  • Running Kotlin on JVMs and Android runtimes
  • Working with the Kotlin Standard Library and advanced features of Kotlin programming
  • Setting up a Kotlin development environment with JetBrains tools
  • Building real-world applications with Kotlin

Who this book is for

This book is intended for anybody who wants to learn the most important Kotlin features. No experience of Kotlin is expected.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Kotlin Quick Start Guide
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Introducing Kotlin
    1. Compiling and running Kotlin
    2. Kotlin's uses
    3. Java interoperability
    4. Build tools
      1. Gradle
      2. Maven
    5. Setting up the development environment
    6. Summary
  8. Kotlin Basics
    1. Functions
    2. Local variables
    3. Local functions
    4. Type inference
    5. Basic types
      1. Numbers
      2. Boolean
      3. Characters
      4. Strings
      5. Base type
      6. Arrays
    6. Nullable types
    7. Casting
      1. Safe casting
    8. Control flow
      1. if-else
      2. When
      3. Loops
        1. For loops
        2. While loops
        3. Do-While loops
    9. Exceptions
      1. Equality comparison
    10. Packages
    11. Visibility modifiers
    12. Summary
  9. Classes and Object-Oriented Programming
    1. Classes
    2. Properties
    3. Class constructors
      1. Primary constructors
      2. Secondary constructors
      3. Final by default
      4. Constructing class instances
    4. Nested classes
    5. Enum classes
    6. Data classes
    7. Inheritance
    8. Overriding members
    9. Abstract classes
    10. Interfaces
    11. Interfaces versus abstract classes
    12. Object keyword
      1. Singletons with object keyword
      2. Companion objects
        1. Static with companion objects
      3. Anonymous objects
    13. Class delegation
    14. Sealed classes
    15. Smart casts
    16. Summary
  10. Functions and Lambdas
    1. Advanced functions
      1. Named arguments
      2. Default parameters
      3. Variable function arguments
    2. Lambdas
      1. Returning a value from a lambda
      2. Passing lambdas as the only or last argument
      3. Closures
      4. Returning from lambdas
    3. Function types
      1. Defining function types
      2. Calling function types
      3. Naming parameters of function types
      4. Calling function types from Java
      5. Lambdas and SAM types
      6. Member references
      7. Inlining lambdas
      8. noinline
      9. crossinline
    4. Summary
  11. Advanced Kotlin
    1. Generics
      1. Declaring generic types
      2. Generic functions
      3. Generic constraints
      4. Type erasure and raw types
      5. Reified generics
    2. Concurrency constructs
      1. Starting a thread
      2. Synchronized methods
      3. Synchronized blocks
      4. Volatile
    3. Delegated properties
      1. Standard library delegate properties
        1. lazy
        2. observable
        3. vetoable
        4. notNull
    4. Extension functions
      1. Importing extension functions
      2. Java interoperability
    5. Extension properties
    6. Receiver functions
    7. Infix functions
    8. Building a simple DSL
    9. Operator overloading
      1. Overloading with extension functions
      2. Operator overloading and Java
      3. Bitwise operations
    10. Summary
  12. Kotlin Standard Library
    1. Collections
      1. Lists
      2. Sets
      3. Maps
      4. Indexing
      5. Platform types and immutable collections
    2. Working with collections
      1. Filtering functions
        1. Drop
        2. Filter
        3. FilterNot
        4. Take
      2. General functions
        1. Any
        2. All
        3. Count
        4. ForEach
        5. Max
        6. Min
        7. Sum
      3. Transforming functions
        1. Map
        2. FlatMap
        3. GroupBy
        4. AssociateBy
      4. Items functions
        1. Contains
        2. First
        3. FirstOrNull
        4. Last
        5. LastOrNull
        6. Single
        7. SingleOrNull
      5. Sorting functions
        1. Reversed
        2. Sorted
        3. SortedDescending
    3. Kotlin standard library functions
      1. Contracts
        1. Check
        2. CheckNotNull
        3. Require
        4. RequireNotNull
        5. Error
      2. Standard functions
        1. Apply
        2. Let
        3. With
        4. Use
    4. Summary
  13. Coding a Dictionary App with Kotlin
    1. Project setup
      1. App features
      2. Requirements
      3. Creating the Kotlin-Gradle project
    2. Developing the dictionary app
      1. Preparing the data
      2. Building the UI
        1. Loading scene
        2. Main Scene
    3. Summary
  14. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.147.83.28