Kotlin Tutorial

Kotlin Tutorial – Learn Kotlin programming language to develop Desktop Applications and Android Applications with ease. These tutorials have been designed to present you the basics and new idiomatic approach because of which Kotlin has become popular. Many example programs are presented with the concepts.

Kotlin Tutorial

Kotlin is relatively a new statically-typed language by 2017, developed by JetBrains. Kotlin is targeted to run on Java Virtual Machine (JVM). Kotlin addresses most of the redundancies in Java programming language, and also new features have been added that could make application development faster and easier and most importantly lot of fun.

There are other new languages with new features that could run on JVM, but Kotlin excels in the reduced compile time (comparable to the time taken by Java Compiler) when compared to other languages.

Also, Kotlin is concise and expressive while maintaining a good compatibility with existing Java stack. And Kotlin could be written alongside Java or we could convert existing Java classes to Kotlin files or classes using Intellij IDEA. All these features make it easy for a Java developer to get started with Kotlin.

That being said, first stable version of Kotlin, Kotlin 1.0 has been released on 15th, Feb 2016. JetBrains would provide backwards compatibility for Kotlin 1.0 for a long time. Also Google added Kotlin as an officially supported language for Android Application development, which is available from Android Studio 3.0.

Prerequisites for this Kotlin Tutorial

Understanding of Java Basics would help a lot in learning Kotlin quickly. However this Kotlin Tutorial is designed to address both groups of audience, with and without Java Programming skills.

IDE (Integrated Development Environment)

Applications using Kotlin Language could be developed on IntelliJ IDEA. Eclipse or any editor could also be used along with a compiler to compile from the command line.

Android Applications could be developed using Kotlin from Android Studio verion 3.0. Android Studio has added Kotlin to its officially supported languages list, which already has Java and C++. Follow Kotlin Android Tutorial to develop Android Applications using Kotlin programming language.

Kotlin Tutorial Index

In this Kotlin Tutorial, we shall learn Kotlin language from very basics.

Kotlin Environment Setup

First and foremost thing to do is, setting up your environment to work with Kotli.

  1. Setting up IDE for Kotlin
  2. HelloWorld Kotlin Program

Having setup our environment and a taste of Kotlin program, lets understand the basics of Kotlin.

Kotlin Basics

Kotlin Basics covers the topics to get you started with Kotlin – like Kotlin Classes, how primary and secondary constructors work, Data Classes, looping statements, decision making statements, how you could extend the functionality of a class, enum classes and some new concepts like Null Safety.

  1. Kotlin main function
  2. Kotlin Classes and Constructors
  3. Kotlin Data Classes
  4. Kotlin Loops
  5. Kotlin When expression
  6. Kotlin Extension Functions
  7. Kotlin Null Safety
  8. Kotlin Enum Classes
  9. Kotlin use function

We have learnt the basics of Kotlin programming language. Now we shall see how to handle some of the errors that occur during the Kotlin application development.

Kotlin String Operations

It is very necessary to know about String Operations in programming applications. Following topics take you through some of the String Operations that are commonly used.

  1. Compare Strings in Kotlin
  2. Split String to Lines

Working with Files in Kotlin

If your application requires working with files which needs operations like reading, writing, modifying and appending content in a file or moving files from one location to another and such, following are the tutorials that help you with file operations.

  1. Kotlin – Reading content of File
  2. Kotlin – Read content of a File as List of lines
  3. Kotlin – Writing content to File
  4. Kotlin – Append text to File
  5. Kotlin – Copy file to other location
  6. Kotlin – Iterate through all files in Directory

Kotlin Interfacing to Database

If your Kotlin Application needs interfacing to a database, following topics explain how to connect to different databases.

  1. Connect to MySQL Database from Kotlin using JDBC

Kotlin Error Handling

This section of tutorials focus on how to handle most frequently occurring errors during programming in Kotlin.

  1.  Kotlin – Primary constructor call expected
  2.  Kotlin – Variable must be initialized
  3.  Kotlin – Null cannot be a value of a non-null type

Interview Questions & Answers

Find different possible questions and respective answers for Kotlin programming :

  1. Kotlin Interview Questions

Conclusion :

By following these tutorials, you would definitely learn Kotlin basics and tools required to work with applications using Kotlin programming language.