Show Posts in

Kotlin Arrays

We’re gonna learn about arrays in Kotlin. Arrays are nothing but continuous memory locations referred with a common name. Arrays are a collection of elements. The individual elements in an array are accessed using the index. The index always starts at 0. That means, the first element in …

Kotlin Inheritance

This post is about inheritance in Kotlin. Inheritance is an important object-oriented programming concept. Read my post on object-oriented programming, and on classes before reading this. If you already have an idea about classes and inheritance, then continue reading. You already know what classes and objects are. Now, …

Kotlin Constructors

This post is about constructors in Kotlin. I recommend you to read my post about Kotlin Classes before reading this. Constructors are functions associated with a class, that are run automatically when the objects are created to initialize the properties of that object. In Kotlin there are two …

Kotlin Classes

Classes and objects form the core of object oriented programming. Kotlin classes are simple and concise compared to classes in other programming languages. Read my post about object oriented programming to get an idea about what are classes and objects. So, the class is the mold and we …

Kotlin Function Overloading

Kotlin supports function overloading. Function overloading means the ability to define more than one function with the same name. Now two questions may arise in your mind. One, why do we have to define two functions with the same name when we can always give different names. Two, …

Kotlin varargs

Read my post about functions before this. Kotlin supports a variable number of arguments (varargs). That means, when you write a function, you can make it in such a way that it accepts any number of arguments. See the above example. The keyword vararg is used to denote …

Kotlin – Functions

In this post, we’re talking about functions. In high school math, we’ve studied trigonometric functions. Do you remember them? We give input to them and we obtain some output. When we give a value to sin(), it gives a result. The functions in programming are kinda the same. …

Kotlin – Receiving User Input

So far, in all the programs, we were supplying the values of the variables manually. But that’s not what we want always. There should be some way to receive input values from the user. Kotlin provides a simple way to do this. We can use the function readLine() …

Kotlin – Loops

Loops are very important in programming and you’ll be using them very often. Unlike most other languages, Kotlin loops are expressive. We can understand what the code does by just looking at it. So, before diving into the syntax and examples of loops in Kotlin, let’s look at …

Kotlin Conditionals – when statement and when expression

In the previous post, we’ve seen if statements and if expressions in Kolin. Now we’ll see how to use the Kotlin conditionals – when statements and when expressions in our programs. If you come from a Java background (or C family for that matter. C, C++, Java etc), …