Soumak De has Published 84 Articles

How does the reified keyword work in Kotlin?

Soumak De

Soumak De

Updated on 27-Oct-2021 11:02:33

3K+ Views

"reified" is a special type of keyword that helps Kotlin developers to access the information related to a class at runtime. "reified" can only be used with inline functions. When "reified" keyword is used, the compiler copies the function’s bytecode to every section of the code where the function has ... Read More

What is the Kotlin double-bang (!!) operator?

Soumak De

Soumak De

Updated on 27-Oct-2021 10:59:30

3K+ Views

In Kotlin, "!!" is an operator that is known as the double-bang operator. This operator is also known as "not-null assertion operator". This operator is used to convert any value to a non-NULL type value and it throws an exception if the corresponding value is NULL. In the following example, ... Read More

Difference between List and Array types in Kotlin

Soumak De

Soumak De

Updated on 27-Oct-2021 10:56:27

4K+ Views

List and array are two popular collections supported by Kotlin. By definition, both these collections allocate sequential memory location. In this article, we will take an example to demonstrate the difference between these two types of collections.AttributeArrayListImplementationArray is implemented using Array classList or MutableList interfaces are used to implement a ... Read More

Extend data class in Kotlin

Soumak De

Soumak De

Updated on 27-Oct-2021 10:52:51

3K+ Views

Data class is a class that holds the data for an application. It is just like a POJO class that we use in Java in order to hold the data.In Java, for data class, we need to create getter and setter methods in order to access the properties of that ... Read More

What are constants in Kotlin and how to create them?

Soumak De

Soumak De

Updated on 27-Oct-2021 10:43:14

3K+ Views

In every programming language, we need some variable whose value will never change thoroughout the program. In Kotlin too, we have a keyword to create such a variable whose value will remain as constant throughout the program. In order to declare a value as constant, we can use the "const" ... Read More

Sort collection by multiple fields in Kotlin

Soumak De

Soumak De

Updated on 27-Oct-2021 09:16:39

929 Views

A Collection is an object where developers can group different types of related objects in one place. There are different kinds of collections present in Kotlin library such as List, Array, etc.In this article, we will see how we can sort a collection by different properties present inside that collection. ... Read More

How to initialize an array in Kotlin with values?

Soumak De

Soumak De

Updated on 27-Oct-2021 09:00:20

1K+ Views

An array is a type of data structure that contains a definite number of similar types of values or data. In this data structure, every element can be accessed using the array index that usually starts at "0".In Kotlin, arrays can be created using the function arrayOf() or using an ... Read More

What is the difference between "var" and "val" in Kotlin?

Soumak De

Soumak De

Updated on 27-Oct-2021 08:56:40

2K+ Views

In Kotlin, we can declare a variable using two different keywords: one is var and the other one is val. In this article, we will take an example and demonstrate how these declarations are different from each other.AttributevarvalDeclarationvar varName="hello World"val sName = "tutorialspoint.com"ImmutabilityMutableImmutableNo. of times a variable can be assigned Can ... Read More

What is the difference between "const" and "val" in Kotlin?

Soumak De

Soumak De

Updated on 27-Oct-2021 08:54:22

6K+ Views

const KeywordThe const keyword is used in Kotlin whenever the variable value remains const throughout the lifecycle of an application. It means that const is applied only on immutable properties of the class. In simple words, use const to declare a read-only property of a class.There are some constraints that ... Read More

Kotlin – Property initialization using "by lazy" vs. "lateinit"

Soumak De

Soumak De

Updated on 27-Oct-2021 08:51:06

10K+ Views

Kotlin library provides two different access modifiers for property declaration.In this article, we will highlight the difference between these two access modifiers and how we can use them in our application.LateinitIn order to create a "lateInit" variable, we just need to add the keyword "lateInit" as an access modifier of ... Read More

Advertisements