Basic HTML version of Foils prepared 9 Sept 1997

Foil 36 Java Language -- Interfaces - Overview

From Java to be used in (Scientific) Computing Part II: Java Language and Object-Oriented Concepts Basic Simulation Track for Computational Science CPS615 -- Fall Semester 97. 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 Sun Feb 22 1998