Interfaces
- As a variation, a specification of a set of operations to be "implemented" can be more easily defined by the way of an
interface
:
public interface Element { public int count(); }
public abstract class NamedElement implements Element { ... }
As a consequence, if a class can only extends a single class, it can implement
many interfaces.
- There are many interface that can be used to integrate user defined class into Java API with for instance:
interface Comparable { int compare(Object o); } // use to sort collection
interface Iterator { boolean hasNext(); Object next(); }// use to loop on collections
interface Iterable { Iterator iterator(); } // complementary of the previous one
interface Runnable { void run(); } // for flow of control
// and multitasking
...
UML/SysML class diagram
11 - 14
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented