Visibility Modifiers in Kotlin 1. Introduction The Kotlin programming language is built upon the Java Virtual Machine (JVM). As such, it has to follow all of the rules that the JVM imposes – including visibility modifiers. However, there are some subtle nuances in how the language implements these modifiers with… Continue Reading kotlin-visibility-modifiers

Initializing Arrays in Kotlin   1. Overview In this quick tutorial, we’ll look at how we can initialize an array in Kotlin. 2. arrayOf Library Method Kotlin has a built-in arrayOf method which converts the provided enumerated values into an array of the given type: val strings = arrayOf(“January”, “February”, “March”)… Continue Reading kotlin-initialize-array

Lambda Expressions in Kotlin 1. Overview In this article, we’re going to explore Lambdas in the Kotlin language. Keep in mind that lambdas aren’t unique to Kotlin and have been around for many years in many other languages. Lambdas Expressions are essentially anonymous functions that we can treat as values… Continue Reading kotlin-lambda-expressions

Create a Java and Kotlin Project with Maven 1. Introduction In this quick tutorial, we’ll see how to set up a Maven project handling both Java and Kotlin sources. We’ll first create a project for Java sources only. We’ll then add the kotlin-maven-plugin to handle Kotlin as well. And finally, we’ll add some dummy classes, package our application,… Continue Reading kotlin-maven-java-project

Concatenate Strings in Kotlin 1. Introduction In this short tutorial, we’ll investigate different ways of concatenating strings in Kotlin. 2. Using the plus() Method Kotlin’s String class contains a plus() method: operator fun plus(other: Any?): String (source) It returns a String obtained by concatenating reference String with the String passed as… Continue Reading kotlin-concatenate-strings

String Comparison in Kotlin 1. Overview In this tutorial, we’ll discuss different ways of comparing Strings in Kotlin. 2. Comparison Operators Let’s start with the “==” operator. This operator can be used to check if the strings are structurally equal. It’s the equivalent of using the equals method in Java: val first… Continue Reading kotlin-string-comparison