Classes and Objects
Learn the foundations of object-oriented programming by creating classes and objects.
Kotlin Code
Study the example and understand each part.
class Student(
val name: String,
val age: Int
)
fun main() {
val student =
Student("Brian", 18)
println(student.name)
println(student.age)
}
Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.
Key Concept
Classes describe objects. Objects are actual instances created from those classes.
Expected Output / Result
Brian 18
Finished this lesson?
Mark it complete to update your course progress.