Kotlin Companion Objects In this article, you will learn to create and use companion objects in your Kotlin program with the help of examples. Before taking about companion objects, let’s take an example to access members of a class. class Person{ fun callMe() = println(“I’m called.”) } fun main(args: Array<String>) { val p1 = Person() …
Day: May 4, 2021
Kotlin Object Declarations and Expressions In this article, you will learn about object declarations (singletons) and object expressions with the help of examples. Object Declarations Singleton is an object-oriented pattern where a class can have only one instance (object). For example, you are working an application having SQL database backend. You want to create a …
Kotlin Sealed Classes In this article, you will learn about Sealed class, how they are created, and when to use them with the help of examples. Sealed classes are used when a value can have only one of the types from a limited set (restricted hierarchies). Before going into details about sealed classes, let’s explore …
Kotlin Data Class In this article, you will learn to create data classes in Kotlin. You will also learn about requirements that data class must fulfill, and their standard functionalities. There may arise a situation where you need to create a class solely to hold data. In such cases, you can mark the class as …
Kotlin Nested and Inner Class In this article, you will learn to work with nested and inner classes with the help of examples. Kotlin Nested Class Similar like Java, Kotlin allows you to define a class within another class known as nested class. class Outer { … .. … class Nested { … .. … …
Kotlin Interfaces In this article, you will learn about interfaces and how to implement it in Kotlin with the help of examples. Kotlin interfaces are similar to interfaces in Java 8. They can contain definitions of abstract methods as well as implementations of non-abstract methods. However, they cannot contain any state. Meaning, interface may have …
(How to setup Dropout Regularization in Keras) In this Learn through Codes example, How to setup Dropout Regularization in Keras. Dropout_Regularization_on_the_Visible_Layer Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects for Aspiring Data Scientists: Tabular Text & Image Data Analytics as well as Time Series Forecasting …
Kotlin Abstract Class In this article, you will learn about abstract class and how to implement it in Kotlin (with the help of examples). Like Java, abstract keyword is used to declare abstract classes in Kotlin. An abstract class cannot be instantiated (you cannot create objects of an abstract class). However, you can inherit subclasses from …
Kotlin Visibility Modifiers In this article, you will learn about all 4 visibility modifiers in Kotlin and how they work in different scenarios. Visibility modifiers are keywords that set the visibility (accessibility) of classes, objects, interface, constructors, functions, properties and their setters. (You cannot set visibility modifier of getters as they always take the same visibility …
Kotlin Inheritance In this article, you’ll learn about inheritance. More specifically, what is inheritance and how to implement it in Kotlin (with the help of examples). Inheritance is one of the key features of object-oriented programming. It allows user to create a new class (derived class) from an existing class (base class). The derived class …