Soumak De has Published 84 Articles

How to split a String into an array in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 12:00:07

2K+ Views

In this article, we will take a couple of examples to demonstrate how we can split a given String in Kotlin using some given delimiters.Example – Split a String using given delimitersIn this example, we will create a String and we will store some value in it and we will ... Read More

Kotlin 'when' statement vs Java 'switch'

Soumak De

Soumak De

Updated on 01-Mar-2022 11:56:33

659 Views

Switch-case statement in any programming language allows the programmers to testify it against different values. It also provides an option to do something whenever the value of the variable does not match with a given value. In this article, we will take a simple example and demonstrate how we can ... Read More

How to check if a string is empty in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 11:45:39

4K+ Views

In this article, we will see three different ways to check whether a String is empty in Kotlin.Example – isEmpty()Kotlin library function isEmpty() can be used in order to check whether a String is empty. Note that it counts spaces too.fun main(args: Array) {    // No space between ... Read More

How to reverse a Map in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 11:41:15

366 Views

Kotlin provides four types of constructors to define and manipulate a HashMap. In this article, we will see how we can reverse a map using Kotlin library function.A Map is a collection where data is stored as a key-value pair and the corresponding key has to be unique.A HashMap is ... Read More

How to convert TimeStamp to DateTime in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 11:37:27

5K+ Views

Kotlin is a statistically typed language and it is based on Java, hence all the Java code can easily be compiled within Kotlin code. In this article, we will see how we can generate the current local date and time in Kotlin.As Kotlin is interoperable with Java, we will be ... Read More

Print 0001 to 1000 in Kotlin with padding

Soumak De

Soumak De

Updated on 01-Mar-2022 11:33:48

147 Views

In this example, we will see how to print 0001 to 1000 in Kotlin with padding. For this purpose, we will use a Kotlin library function called padStart().padStart is a function which returns a charSequence. Its function definition looks like this −fun CharSequence.padStart( length: Int, ... Read More

Equality checks in Kotlin (Difference between "==" and "===" Operators)

Soumak De

Soumak De

Updated on 01-Mar-2022 11:16:42

1K+ Views

Kotlin is statistically typed language and it is hundred percent comparable with Java, as it was developed based on JVM. In Kotlin, there are two types of equality checks −One is denoted by "==" andThe other one is denoted by "===".As per the official documentation, "==" is used for structural ... Read More

How to remove an item from an ArrayList in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 11:13:33

2K+ Views

In this article we will see how we can remove an item from an ArrayList using Kotlin library function. In order to do that, we will take the help of a library function called drop(). The function definition looks as follows −fun Array.drop(n: Int): List (source)It takes array and ... Read More

How to create a list in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 11:09:32

954 Views

A list is a collection to hold same type of data in a single variable. Kotlin does not provide any dedicated literal to create a collection. As per the documentation of Kotlin, a List is an ordered collection with access to elements by indices.In Kotlin, we do have two different ... Read More

How to create an empty array in Kotlin?

Soumak De

Soumak De

Updated on 01-Mar-2022 11:01:38

314 Views

An array is a collection where we can store multiple items of the same type. We can consider an array of integers or an array of strings. This is very useful, for example, whenever we need to store the name of 1000 students in a single variable.Example – Using arrayOf()In ... Read More

Advertisements