Extending an Interface

Another interface can extend from another interface by using the extends keyword. Since adding a new method definition to the interface breaks the API, extending is considered a good practise.

Example Extending

The List interface extends the Collection interface by providing more methods specific to the List. Ignore the m<E> for now in the definition. The <E> is a generic we will cover that in a future section.

public interface List<E> extends Collection<E> {}

Also the Set interface extends the Collection by adding Set specific method definitions :

public interface Set<E> extends Collection<E> {}


A class implements an interface. An interface extends another interface.

results matching ""

    No results matching ""