kotlin

kotlin

Kotlin groupingBy explanation with example

groupingBy function is used to group items and apply one operation using a keySelector function. It returns one Grouping object that we can use to call its other methods. In this post, I will quickly show you how to use groupingBy with examples.

Read
kotlin

Kotlin groupByTo method explanation with examples

groupByTo method is used to group elements of an array by a key returned by a key selector function. It is similar to groupBy. The only difference is that we can put the result in a mutable map.

Read
kotlin

Kotlin groupBy method explanation with example

groupBy method of Kotlin is used to group similar items of a collection. It is useful in many cases like we can group items based on type, length, object category, etc. It takes one selector function and based on that function it groups the items.

Read
kotlin

Different ways to convert string to long in Kotlin

In this post, I will show you different ways to convert one string to long in Kotlin. Kotlin provides different methods that make it easy to achieve.

Read
kotlin

Kotlin program to convert one character to integer

In this tutorial, I will show you how to convert one character to integer in Kotlin. Kotlin provides a lot of utility functions for each class.

Read
kotlin

Kotlin program to remove character at specific index of a String

String is immutable in Kotlin. If we want to change any character in a string, we can't directly change it. For that, we need to create one new string modifying the given string. In this tutorial, we will learn different ways to do that in Kotlin.

Read
kotlin

Kotlin program to find the positive value of negative numbers

In this tutorial, we will learn how to convert one negative number to positive in Kotlin. We will learn two different ways to do that.

Read
kotlin

How to partition a list in Kotlin

Partitioning or dividing a list or any other collection is easy in Kotlin. Kotlin provides one inbuilt method that makes it easier for us. In this post, I will show you how to do partition using and without using the provided function.

Read
kotlin

Kotlin program to remove all negative numbers from a list

In this tutorial, we will learn how to remove all negative numbers from a mutable list. For example, if the list is 1,2,3,4,5,-6,-7,-8,9, it will remove all negative numbers and convert it to 1,2,3,4,5,9.

Read
kotlin

Kotlin companion object explanation with example

For normal classes, if we want to access any of its property, like calling a method or accessing any variable in the class, we need to create one object for that class. If we don't want to create one class instance and access its members, we need to create one companion object. Unlike other programming languages like Java or Python, Kotlin doesn't have the concept of static function.

Read