An interface is a contract that defines what a class must be able to do. A class can implement more than one interface, which makes it useful for organizing behavior cleanly.
kotlin
interface Drivable {
fun drive()
}
class Car : Drivable {
override fun drive() {
println("Driving a car")
}
}
fun main() {
val car = Car()
car.drive()
}You should see
Driving a carSummary
Interfaces let you write classes against a shared, well-organized contract.