Kotlin - Interface

Kotlin - Interface is much similar to Java 8 .

nterface might be done by methods for a class that enables you to utilize its portrayed capacity

The watchword "interface" is utilized to characterize an interface in Kotlin as appeared inside the accompanying bit of code.


interface ExampleInterface 

var myVar: String/dynamic property 

a snicker absMethod()/synopsis approach 

a snicker sayHello() = "Hi World!"/technique with default execution 

Take a gander at the trademark named "sayHello()", which is an executed procedure.

In the accompanying model, we can be actualizing the above interface in a class.


interface ExampleInterface 

var myVar: Int/rundown property 

interesting absMethod():String/theoretical strategy 

interesting hi() 

println("Hello there, Welcome to Welookups.Com!") 

superbness InterfaceImp : ExampleInterface 

abrogate var myVar: Int = 25 

abrogate a snicker absMethod() = "Begin Learning " 

fun essential(args: Array) 

val obj = InterfaceImp() 

println("My Variable Value is = $obj.MyVar") 

print("Calling howdy(): ") 

obj.Hi there() 

print("Message from the Website- - ") 



Calling whats up(): Hello there, Welcome to Welookups.Com! 

Message from the Website- - Start Learning 

Kotlin doesn't help a few inheritances

In the accompanying model, we can make two interfaces and later we can put into impact both the interfaces into a clas


interface A 

fun printMe() 

println(" technique for interface A") 

interface B 

entertaining printMeToo() 

println("I am some other Method from interface B") 

/executes two interfaces An and B 

class multipleInterfaceExample: A, B 

a snicker foremost(args: Array) 

val obj = multipleInterfaceExample() 



In the above example, we've made example interfaces A, B and in the polish named "multipleInterfaceExample"


technique for interface A 

I am another Method from interface B