Creating the interfaces

The interface in our case is very simple:

public interface Sort {
    void sort(Sortable collection);
}

The interface should do only one thing, sort something that is sortable. As such, we define an interface and any class that implements this interface will be Sortable:

public interface Sortable {
}

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.