Constructing class instances

Kotlin doesn't have the new keyword, like Java or C# have. If you want to construct a class in Kotlin, you call its constructor like you would call a function. Here's how we would create an instance of our User class:

val user = User("Bruce", "Wayne", "1950")
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.50.252