Soumak De has Published 84 Articles

How to check if a "lateInit" variable has been initialized in Kotlin?

Soumak De

Soumak De

Updated on 27-Oct-2021 08:41:14

3K+ Views

Any variable which is initialized after its declaration is known as a "late initialized variable". In conventional programming languages, any non-NULL type of variable need to be initialized in the constructor. But sometimes, by mistake, developers forget to do these NULL checks which causes a programming error. In order to ... Read More

What is the equivalent of Java static methods in Kotlin?

Soumak De

Soumak De

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

317 Views

In Java, "static" keyword is used for efficient memory management. Once a variable or method is declared as static, then the JVM will allocate memory for these variable only once. Usually static variables are used to declare common properties of a class, for example, "Name of the institution". In the ... Read More

Throw Custom Exception in Kotlin

Soumak De

Soumak De

Updated on 27-Oct-2021 07:56:24

800 Views

Exception is an important aspect of any programming language. It prevents our code from generating incorrect output at runtime.The concept of exception in Kotlin is very much same as it is in Java. All the exceptions in Kotlin are the descendants of Throwable class. In Kotlin, developers do have the ... Read More

How to iterate over a Hashmap in Kotlin?

Soumak De

Soumak De

Updated on 27-Oct-2021 06:22:01

2K+ Views

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 a collection class based upon MutableMap interface and it does that by implementing MutableMap interface of HashTable. Kotlin provides four types of constructor to define and ... Read More

Previous 1 ... 5 6 7 8 9
Advertisements