Basic HTML version of Foils prepared 18 May 97

Foil 63 Java Language -- Interfaces - Overview

From Java Tutorial - Spring 1997 Part II: Java Language and Object-Oriented Concepts Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


An interface specifies a collection of methods (behaviors) without implementing their bodies (akin to giving the API).
  • public interface Storable {
    • public abstract void store(Stream s);
    • public abstract void retrieve(Stream s);
    • }
Any other class which implements the interface is guaranteeing that it will have the set of behaviors, and will give concrete bodies to the methods of the interface.
Interfaces solve some of the same problems as multiple inheritance, without as much overhead at runtime.
  • There is a small performance penalty because interfaces involve dynamic method binding.
Interfaces can be implemented by classes on unrelated inheritance trees, making it unnecessary to add methods to common superclass.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Thu Jan 8 1998