Creating a Person Class
Define a Kotlin class with properties and methods to represent a person and interact with their data.
Define a Kotlin class with properties and methods to represent a person and interact with their data.
class Person(val name: String, var age: Int) {
fun sayHello() {
println("Hello, my name is $name!")
}
}
Usage:
val person = Person("Alice", 30)
person.sayHello()