Hey there! In this article I’m going to show you how to make your first program in Kotlin on IntelliJ IDEA.
The program that we are going to write is pretty simple. Its only purpose is to print a simple “Hello World!” text to the screen. The goal is to illustrate the basic syntax of Kotlin and how to run the code.
You have already used functions like print and println in hello world lesson. Those are called predefined standard library. There is also user defined functions which is the functions you made yourself.
In this lesson we’re going to talk about more about functions. This is going to be fun!
Function is a named sub-program which performs a specific task. We need to call the function by name to execute the sub-program. You can think of a function as a machine.
Mathematical operations like addition, substraction, multiplication, and division comes built-in with Kotlin.
However there are more available basic operators we can use to perform operations on variables and values. Learning these operators is important as you will do operations on variable and values a lot.
In the example below, we use the
+ operator to add together two values, a variable with a value, and a variable with another variable.
We will learn four different categories of operators : arithmetic, assignment, comparison, and logical. You can use all four of them for operations of two values, a…
A data type is an attribute of data which tells the compiler or interpreter what type of value the data contains. Based of the illustration variables as boxes before, we can think of the data types as color of the paper, each color can only hold one type of data (yellow for strings, blue for integers, and green for booleans).
Ahh, yes. Variables, one of the most important concepts in a programming language.
If you have some experiences in coding before, you might have an idea why I put that pic on the left. But if you are new and still confused, don’t worry because you will get it in a second. So, let’s just jump right into it. Shall we?
Often times when you are coding, you will have to deal with data. You will have to deal with data from your application input, process, and output. And it will be extremely exhausting if you don’t know how to…
Kotlin was created back in 2010 by JetBrains and named after an island located near their headquarter in St. Petersburg.
About seven years later — in 2017 — Google announces their support for Kotlin on Android Development. Two years after that, Google announces Android Development will be increasingly Kotlin first.
Now that you know a little bit of the Kotlin background and that Google puts priority on Kotlin instead of C++ or Java (which are also supported for Native Android Development), you might ask :
What’s so good about Kotlin then?
I’m already comfortable working with Java. …