SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

KOTLIN / NOTES</>↗
Kotlin20 Jun 2026

How do I use class inheritance with open and override in Kotlin?

In Kotlin, classes and members are final by default, so you must explicitly mark them as open if you want them to be inherited or overridden. Basic class inheritance open class Animal { open fun makeSound() { println("Some sound") } } class Dog : Animal() { override fun makeSound() { println("Bark") } } Usage: fun […]

Wayan · 3 min read
KOTLIN / NOTES</>↗
Kotlin20 Jun 2026

How do I use the init block to run setup logic in Kotlin classes?

In Kotlin, an init block runs setup logic when a class instance is created. It is commonly used to validate constructor arguments, initialize derived properties, or perform other construction-time setup. class User(val name: String, val age: Int) { init { require(name.isNotBlank()) { "Name must not be blank" } require(age >= 0) { "Age must be […]

Wayan · 2 min read
KOTLIN / NOTES</>↗
Kotlin20 Jun 2026

How do I override the toString(), equals(), and hashCode() methods in Kotlin?

In Kotlin, you usually don’t manually override toString(), equals(), and hashCode() if your class is just a value/data holder. Use a data class instead. data class User( val id: Int, val name: String ) Kotlin automatically generates: toString() equals() hashCode() copy() componentN() Example: val a = User(1, "Alice") val b = User(1, "Alice") println(a) // […]

Wayan · 2 min read
KOTLIN / NOTES</>↗
Kotlin19 Jun 2026

How do I use data classes in Kotlin to store structured data?

In Kotlin, data classes are designed to store structured data with minimal boilerplate. A data class automatically provides useful functions such as: toString() equals() hashCode() copy() component functions for destructuring, like component1(), component2() Basic example data class User( val id: Int, val name: String, val email: String ) You can create and use it like […]

Wayan · 2 min read
KOTLIN / NOTES</>↗
Kotlin19 Jun 2026

How do I use val and var inside Kotlin classes?

In Kotlin classes, val and var are used to declare properties. val means read-only after initialization var means mutable / can be reassigned Basic example class User { val id: Int = 1 var name: String = "Alice" } Usage: fun main() { val user = User() println(user.id) // 1 println(user.name) // Alice user.name = […]

Wayan · 2 min read
KOTLIN / NOTES</>↗
Kotlin19 Jun 2026

How do I define constructors and initialize class properties in Kotlin?

In Kotlin, you usually define constructors and initialize properties directly in the class header using a primary constructor. 1. Primary constructor The most common style is: class Person(val name: String, var age: Int) This defines: a class named Person a read-only property name a mutable property age a constructor that requires both values Usage: fun […]

Wayan · 4 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.