100% found this document useful (1 vote)
911 views

Kotlin Tutorial PDF

The document provides an introduction to the Kotlin programming language, including that it is a statically typed language that runs on the JVM like Java. It then discusses Kotlin basics like classes, functions, and file input/output operations. The document aims to explain the essential concepts of the Kotlin language.

Uploaded by

حنظل ة
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
911 views

Kotlin Tutorial PDF

The document provides an introduction to the Kotlin programming language, including that it is a statically typed language that runs on the JVM like Java. It then discusses Kotlin basics like classes, functions, and file input/output operations. The document aims to explain the essential concepts of the Kotlin language.

Uploaded by

حنظل ة
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Kotlin Tutorial – Kotlin Programming Language Basics

Kotlin is a statically typed programming language for modern multi-platform applications. Kotlin runs on JVM
like Scala, Groovy, Kawa, etc. This article provides a detailed introduction to Kotlin programming language, its
basics, and examples to understand basic functional programming statements, object-oriented concepts, file
operations, string operations, etc.

Kotlin Tutorial

Kotlin programming language can be used 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.

Kotlin is relatively a new statically-typed language by 2017, developed by JetBrains. Kotlin is targeted to run on
the Java Virtual Machine (JVM). Kotlin addresses most of the redundancies present in Java programming
language, and also new features have been added that could make application development faster, 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 quickly.

That being said, the first stable version of Kotlin, Kotlin 1.0 has been released on 15th, Feb 2016. JetBrains
would provide backward 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
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 for Kotlin Development
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 version 3.0. Android Studio has
added Kotlin to its officially supported languages list, which already has Java and C++. FollowKotlin Android
Tutorial to develop Android Applications using Kotlin programming language.

Kotlin Environment Setup


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

Setting up IDE for Kotlin


HelloWorld Kotlin Program

Having set up our environment and a taste of Kotlin program, let us understand the basics of Kotlin.

Kotlin Basics
Kotlin Basics cover 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.

Kotlin main function


Kotlin Classes and Constructors
Kotlin Data Classes
Kotlin Loops
Kotlin When expression
Kotlin Extension Functions
Kotlin Null Safety
Kotlin Enum Classes
Kotlin use function

We have learned 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.

Tutorial – Compare Strings in Kotlin


Tutorial – Split String to Lines in Kotlin

Working with Files in Kotlin


If your application requires working with files which need 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.

Reading the content of File – Kotlin Examples


Read the content of a File as List of lines – Kotlin Examples
Writing content to File – Kotlin Examples
Append text to File – Kotlin Examples
Copy a file to other location – Kotlin Examples
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.

Connect to MySQL Database from Kotlin using JDBC

Kotlin Error Handling


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

Tutorial – Kotlin Error: Primary Constructor call expected


Tutorial – Kotlin Error: Variable must be initialized
Tutorial – Kotlin Error: Null cannot be a value of a non-null type

Interview Questions & Answers


Find different possible questions and respective answers for Kotlin programming :

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.

Kotlin Java

⊩ Kotlin Tutorial

Getting Started

⊩ Kotlin - Setup Kotlin(Java) Project

⊩ Kotlin - Basic Program Example

⊩ Kotlin - Convert Java File to Kotlin File

⊩ Kotlin - Main Function

⊩ Kotlin for loop, forEach


⊩ Kotlin while, do-while loops

⊩ Kotlin repeat

⊩ Kotlin - Ranges

⊩ Kotlin - When

Object Oriented Concepts


Classes

⊩ Kotlin - Class, Primary and Secondary Constructors

⊩ Kotlin - Sealed Classes

Inheritance

⊩ Kotlin - Inheritance

⊩ Kotlin - Override Method of Super Class

Abstraction

⊩ Kotlin - Abstraction

⊩ Kotlin - Abstract Class

⊩ Kotlin - Interfaces

Data Class

⊩ Kotlin - Data Class

⊩ Kotlin - Enum Classes

⊩ Kotlin - Extension Functions

⊩ Kotlin - Null Safety

Exception Handling

⊩ Kotlin - Try Catch

⊩ Kotlin - Throw Exception

⊩ Kotlin - Custom Exception

Fix Compilation Errors

⊩ Kotlin - Variable must be initialized

⊩ Kotlin - Primary Constructor call expected

⊩ Kotlin - Null can not be a value of a non-null type String

⊩ Kotlin - Cannot create an instance of an abstract class

Kotlin - String Operations

⊩ Kotlin - Compare Strings

⊩ Kotlin - Replace String

⊩ Kotlin - Split String

⊩ Kotlin - Split String to Lines


⊩ Kotlin - String Capitalize

Kotlin - Functions

⊩ Kotlin Function - Default Arguments

⊩ Kotlin - Use Function

Kotlin - Collections
Kotlin - List

⊩ Kotlin List

⊩ Kotlin List - forEach

Kotlin - File Operations

⊩ Kotlin - Create File

⊩ Kotlin - Read Contents of a File

⊩ Kotlin - Read Content of a File as list of lines

⊩ Kotlin - Write Content to a File

⊩ Kotlin - Append Text to a File

⊩ Kotlin - Check if File exists

⊩ Kotlin - Copy a File to Other

⊩ Kotlin - Iterate through all files in a directory

⊩ Kotlin - Delete Recursively

⊩ Kotlin - Get File Extension

Kotlin - Interview Q/A

⊩ Kotlin Interview Questions

Kotlin - Android

⊩ Kotlin Android Tutorial

Useful Resources

⊩ How to Learn Programming

You might also like