Languages Features Creators Calendar CSV Resources Blog About Donate Add Language
GitHub icon


< >
Example from Java, Pizza, Deesel:
interface MyInterface{ /* This is a default method so we need not * to implement this method in the implementation * classes */ default void newMethod(){ System.out.println("Newly added default method"); } /* Already existing public and abstract method * We must need to implement this method in * implementation classes. */ void existingMethod(String str); } public class Example implements MyInterface{ // implementing abstract method public void existingMethod(String str){ System.out.println("String is: "+str); } public static void main(String[] args) { Example obj = new Example(); //calling the default method of interface obj.newMethod(); //calling the abstract method of interface obj.existingMethod("Java 8 is easy to learn"); } }
Example from Swift:
protocol MyProtocol { init(parameter: Int) var myVariable: Int { get set } var myReadOnlyProperty: Int { get } func myMethod() func myMethodWithBody() } extension MyProtocol { func myMethodWithBody() { // implementation goes here } }
Example from Kotlin:
interface Named { val name: String } interface Person : Named { val firstName: String val lastName: String override val name: String get() = "$firstName $lastName" }
// interface SquareConfig { color?: string; width?: number; }
Example from Objective-C, cooC:
@protocol Printing -(void) print; @end
Example from GraphQL:
interface Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! } type Human implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! starships: [Starship] totalCredits: Int } type Droid implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! primaryFunction: String }

Languages with Interfaces include Java, Swift, Kotlin, TypeScript, Objective-C, GraphQL, Pizza, Deesel, cooC, Static Typescript

Languages without Interfaces include progsbase

Read more about Interfaces on the web: 1.

HTML of this page generated by Features.ts

hasIntegers.html 路 hasInterfaces.html 路 hasIterators.html

View source

PLDB - Build the next great programming language Search v2023 Day 157 Docs Acknowledgements Traffic Today Traffic Trends Mirrors GitHub