January 2018
Intermediate to advanced
434 pages
14h 1m
English
As we have just discussed, interfaces in Kotlin can have the implementation of methods; let's follow these mentioned steps to check that out:
interface DemoInterface { fun implementatedMethod() { println("From demo interface") }}
Defining a method with implementation in the interface is just like you would do inside a class.
class IntefaceImplementation: DemoInterface
fun main(args: Array<String>) { var interfaceImplementation= IntefaceImplementation() interfaceImplementation.implementatedMethod()}
Here's the output:
From demo interface
Read now
Unlock full access