Creating a Class() example in Kotlin
Creating a Class() example in Kotlin
In Object-Oriented Programming Languages, the classes are important. You can find a simple Class creating example in this post.
fun main() {
var personA = Person("Mike","Sunshine")
var personB = Person()
var personC = Person(lastName = "Peterson")
}
class Person (firstName:String ="John" , lastName:String="Doe"){
init {
println("A new person object created with First Name: $firstName and " +
"Last Name: $lastName" )
}
}
A new person object created with First Name: Mike and Last Name: Sunshine
A new person object created with First Name: John and Last Name: Doe
A new person object created with First Name: John and Last Name: Peterson
Process finished with exit code 0
Last updated on