Kotlin

Kotlin Set

In this tutorial, we will talk about Kotlin Set with the help of simple examples. Sets are: An unordered collection of elements. Duplicate elements are not allowed in sets. In Kotlin, we can have both a mutable set and an immutable set. Kotlin Immutable Set The immutable set also known as read-only set support only read-only access to the set. Immutable set …

Kotlin SetRead More »

Kotlin Null Safety

This tutorial is about Null Safety in Kotlin. Null Safety in Kotlin is to eliminate the risk of occurrence of NullPointerException from code. One of the most common pitfalls in many programming languages, including Java, is that accessing a member of a null reference will result in a null reference exception. In Java this would …

Kotlin Null SafetyRead More »

Kotlin Data Classes

This tutorial is about Kotlin Data classes, requirements that data class must fulfill, and their standard functionalities. Data Classes Data classes  are classes whose main purpose is to hold data/state and contains standard functionalities. A data keyword is used to declare a class as a data class. Example: data class Student(val name: String, val age: Int) …

Kotlin Data ClassesRead More »

Kotlin Object Declarations and Expressions

This tutorial is about object declarations (singletons) and object expressions with the help of examples. Object Declarations Object declarations defines singletons. Singleton is an object-oriented pattern where a class can have only one instance (object) at a time. Kotlin creates singletons with the object keyword. The object declaration can have functions, properties, and the init …

Kotlin Object Declarations and ExpressionsRead More »

Kotlin Companion objects

This tutorial is about companion objects in Kotlin with the help of examples. Kotlin doesn’t have a static keyword. Static members belong to a type, and not to an instance of a type. In kotlin to achieve this static feature, we make use of companion object. companion object An object declaration inside a class can be …

Kotlin Companion objectsRead More »

Kotlin Getters and Setters

This tutorial is about how to use getters and setters in Kotlin with the help of simple example. Getters and Setters Getters are used for getting value of the property and Setters are used for setting the value of the property. Setters can have visibility modifiers but Getters always have the same visibility as the …

Kotlin Getters and SettersRead More »

Kotlin Visibility Modifiers

This post is about Access/Visibility modifiers in kotlin and how to use them. Access Modifiers In Kotlin, visibility modifiers are used to restrict the accessibility of Classes, objects, interfaces, constructors, functions, properties and their setters to a certain level. Getters always have the same visibility as the property. There are four visibility modifiers in Kotlin: public protected internal …

Kotlin Visibility ModifiersRead More »

Kotlin Interfaces(With Examples)

This article is about interfaces and how to implement it in Kotlin with the help of simple examples. Interfaces In Kotlin, Interfaces can contain declarations of abstract methods (have no body), as well as method implementation of non-abstract methods.  Interfaces can have properties but these need to be abstract or to provide accessor implementations. Creating …

Kotlin Interfaces(With Examples)Read More »

%d bloggers like this: