kotlin

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
kotlin

Kotlin program to check if a string is numeric

In this post, I will show you how to check if a string is numeric or not in Kotlin. For example, "1.2" is a numeric string but 1.2x is not. We will learn different ways to solve this problem.

Read
kotlin

Kotlin program to remove all whitespaces from a string

Kotlin doesn't provide any string method to remove all whitespaces from a string. The only way to do it by replacing all blank spaces with an empty string.

Read
kotlin

Kotlin inheritance explanation with example

Inheritance is a commonly used concept in object-oriented programming. It is the way to inherit functions and properties from a base class to a child class.

Read
kotlin

Kotlin program to filter one list using another list

In this tutorial, I will show you how to filter one list using another list. For example, if the first list contains 1,2,3,4,5 and if the second list contains 2,4,6,7 and if we filter the first list based on the second list, it will give 2,4.

Read
kotlin

Kotlin program to convert one string to character array

In this kotlin tutorial, we will learn how to convert one string to a character array. Kotlin provides one method called toCharArray that can be used to convert one string to character array.

Read
kotlin

Kotlin program to delete all files in a folder

In Kotlin, you don't have to iterate through all files in a folder and delete the files one by one. Kotlin comes with an inbuilt File method called deleteRecursively that can be used to delete all files in a folder. In this post, I will show you how to use deleteRecursively with an example.

Read
kotlin

Convert Java file to Kotlin in Intellij Idea

You can use both Kotlin and Java files in a Kotlin program. Like if you want to move your Android project from Java to Kotlin, you can do that. You can add new files as kotlin files. Or, you can convert your existing Java files as well.

Read
kotlin

Kotlin program to decapitalize the first character of a string

In this post, I will show you two different ways to decapitalize the first character of a string. For example, if the string is 'TWELVE', it will change it to 'tWELVE'.

Read