Why Is That Better?
Home ] Up ] What's The Problem? ] The Solution ] [ Why Is That Better? ] Multiple Inheritance ] What is an Interface? ] Nouns vs. Adjectives ] Interface Inheritance ] Marker Interfaces ]

 

 

So, why do we think that using interfaces is better, in this case?

Using interfaces in Java is essential for adding certain functionality.  For example, we can now add other capabilities simultaneously using additional interfaces:

package company;

import sortable.Sortable;
import persistent.Persistent;
import cloneable.Cloneable; // Fictitious!

public class Employee implements Sortable, Persistent, Cloneable
{
    // ...
}

Note the keyword implements in place of extends, and the fact that you can now specify a comma-separated list of interface names.

This is valid syntax, and compiles without error.

 

This page was last modified on 02 October, 2007