Sobes.tech
Junior — Middle

Milline on alusklass, mis on kõigi klasside esivanem Kotlinis?

sobes.tech AI

Vastus AI-lt

In Kotlin, the base class that is the ancestor of all classes is the Any class. It is similar to the Object class in Java, but contains only three methods: equals(), hashCode(), and toString(). All classes in Kotlin implicitly inherit from Any, unless specified otherwise.

Example:

class MyClass

fun main() {
    val obj = MyClass()
    println(obj.toString()) // Method toString() from class Any
}