Tsallaka zuwa abun ciki
Justice Tech School

Classes

A class has a primary constructor, properties and methods. No new keyword is needed.

Example
class Dog(val name: String) {
    fun speak() = "$name says woof"
}
val d = Dog("Rex")
println(d.speak())

Exercise

Create an object.

val d = ("Rex")

Quiz Test

Is new required to create objects?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.