Soumak De has Published 84 Articles

How to convert an ArrayList to String in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 13:29:18

973 Views

In this article, we will see how we can convert an ArrayList in Kotlin to a String. In order to do so, we will use a String function called joinToString() that is provided by the Kotlin library. Its definition goes like this −fun Array.joinToString(    // the String will ... Read More

How to check generic type in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 13:16:35

4K+ Views

In this article, we will see how we can get the type of a class that is used in Kotlin. There are no direct ways to do this in Kotlin. In order to check the generic type, we need to create an instance of the generic class and then we ... Read More

Kotlin equivalent of Java's equalsIgnoreCase

Soumak De

Soumak De

Updated on 16-Mar-2022 13:12:21

1K+ Views

Java provides a String method called equalsIgnoreCase() which helps developers to compare two strings on the basis of their content. This comparison is case-insensitive, that is, it ignores whether the strings are in uppercase or lowercase and just compares the string values. In this article, we will see how we ... Read More

How to implement switch-case statement in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 13:08:01

7K+ Views

Switch case statement in any programming language is a type of selection control mechanism that allows the developers to test the value of a variable or expression and change the control flow of a program based on the outcome of the comparison. It also provides an option to do something ... Read More

How to create an instance of an abstract class in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 13:03:45

3K+ Views

When a class is defined in Kotlin with an abstract keyword, then it is known as an abstract class. In Kotlin, we cannot create an instance of an abstract class. Abstract classes can only be implemented by another class which should be abstract in nature. In order to use an ... Read More

How to add an item to an ArrayList in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 12:55:22

4K+ Views

In this example, we will see how we can define an ArrayList in Kotlin and add an item in the list. We can do it using the library function add() or we can use the "+=" operator. In order demonstrate, we will be creating two ArrayLists, one is of mutable ... Read More

How to correctly concatenate strings in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 12:50:36

7K+ Views

There are different ways to concatenate strings in Kotlin. For example, we can use the $ operator or we can use the append() function or we can simply use the "+" operator to join two strings.Example – Concatenate Using "$"Kotlin provides an operator to reference a variable or expression. In ... Read More

How to catch many exceptions at the same time in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 12:43:47

2K+ Views

Exception handling is an important feature of any programming language. It restricts our programs from generating incorrect output at runtime. Kotlin does not support throwing multiple exceptions at the same time, however we can implement this functionality using some other functions provided by the Kotlin library.Example – Throwing Multiple ExceptionsIn ... Read More

How to create an array in Kotlin like in Java by just providing a size?

Soumak De

Soumak De

Updated on 16-Mar-2022 12:38:33

791 Views

Kotlin is a cross platform statistically typed language based upon JVM. Kotlin is designed in such a way that it is interoperate fully with Java and JVM. In Java, we can simply create an array by providing a size.Example – Array of Specific Size in JavaThe following example demonstrates how ... Read More

How to create an instance of an anonymous interface in Kotlin?

Soumak De

Soumak De

Updated on 16-Mar-2022 12:21:28

2K+ Views

Kotlin has been developed over JVM, hence it supports most of the features of JVM. Java provides a feature called anonymous inner classes to handle the cases where we have to create an object of a class with a slight modification, without declaring a new subclass. An anonymous inner class ... Read More

Advertisements