Basic HTML version of Foils prepared
Sept 6 1998
Foil 36 Interfaces can be used as Classes in type specification
From
Java Tutorial 98-2: Java Language and Object Oriented Techniques CPS606 Fall Semester 1999 --
Sept 7 1999
.
by
Geoffrey C. Fox, Nancy McCracken
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 Mon Sep 6 1999