Basic HTML version of Foils prepared 9 Sept 1997

Foil 40 Interfaces can be used as Classes in type specification

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


1 Interfaces behave exactly as classes when used as a type.
2 The normal type declaration syntax "interfaceName variableName" declares a variable or parameter to be an instance of some class that implements interfaceName.
  • public class StudentBody {
    • Stream s;
    • Picture id_photo; // of interface storable
    • StudentRecord id_card; // of interface storable
    • . . .
    • public void register() {
    • save(id_photo);
    • save(id_card);
    • }
    • public void save(Storable o) {
    • o.store(s);
    • }
  • }

in Table To:


© 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