Quick actions

cmd+k|ctrl+k

Navigation

Languages

Variance

Snippet info

Language

Kotlin

Visibility

public

Author

habib17

Created

2019-11-04T07:50:40Z

Updated

2019-11-04T09:52:41Z

fun main(args : Array<String>){
    val car = Car(200)
    val motorCycle = MotorCycle(100)
    var vehicle: Vehicle = car
    vehicle = motorCycle
    
    //
    val carList = listOf(Car(100), Car(120))
    val vehicleList = carList
}

abstract  class Vehicle(wheel: Int)
class Car(speed: Int) : Vehicle(4)
class MotorCycle(speed: Int) : Vehicle(2)

INFO