Creating generic interfaces

In this lesson, we will learn how to create generic interfaces.

Generic interface syntax

We can pass types into an interface that are used within its definition like we can to a function. The syntax for a generic interface is below:

interface InterfaceName<T1, T2, ...> {
    ...
}

The members of the interface can reference the generic types passed into it.

Get hands-on with 1200+ tech skills courses.