Input/Output (IO) in Kotlin

Input The readLine() function in Kotlin is a function included in the standard library that allows reading a line of text from the console. It returns the read line as a string. With the help of other special functions such as toInt(), toDouble() or toFloat(), the inputs that are read in as a string can be converted into other data types in order to be processed accordingly later in the program. Below

Read more

Data types in Kotlin

Kotlin is a statically typed programming language, which means that all variables and expressions are checked for their types during compilation (translating the written source code into executable machine code that can be understood by the computer). If one tries to assign a value to a data type that does not match the expected type, an error will occur and the program will stop compiling. This has the advantage that certain

Read more

Variables in Kotlin

A variable is a named area in memory used to store and process data. A variable in Kotlin always has a name, a data type and a value. The name of the variable is a freely selectable identifier that can consist of alphanumeric characters or underscores and must begin with either a letter or an underscore. To define a variable in Kotlin you can do two

Read more

Program structure

Every Kotlin program has an entry point, which is the function called “main”. This function marks the start of program execution and is therefore included in every Kotlin program. Below is a previously familiar section of Kotlin code that prints the message “Hello World!” Now let's take a closer look at the structure of the code. As with other functions in Kotlin, defining the function begins main() with the keyword fun. The abbreviation “fun”

Read more

Installing the development environment and setting up the first Kotlin project

The IntelliJ IDEA development environment from JetBrains can be used to develop Kotlin applications. This environment is available for Windows as well as MacOS and Linux. There is a free version – Community, and a paid one – Ultimate offered. The free version is completely sufficient for learning purposes. We download these from the website https://www.jetbrains.com/idea/download/other.html. Installing IntelliJ IDEA First we start the installer and

Read more