Basic HTML version of Foils prepared 18 May 97

Foil 67 Interfaces can be used as Classes in type specification

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


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 Thu Jan 8 1998