Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Deligation Program

interface Base { 
    fun printMe() //abstract method 
}  
class BaseImpl(val x: Int) : Base { 
    override fun printMe() { println(x) }   //implementation of the method 
}  
class Derived(b: Base) : Base by b  // delegating the public method on the object b  
fun main(args: Array<String>) { 
    val b = BaseImpl(10) 
    Derived(b).printMe() // prints 10 :: accessing the printMe() method  
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.