HELP! * GREY=local LOCAL HTML version of Foils prepared 29 January 1996

Foil 52 Java Language -- Interfaces

From CPS616 Lectures on Java CPS616 Basic Information Track for Computational Science -- Winter-Spring Semester 96. by Geoffrey C. Fox * See also color IMAGE

A class can only have one parent class but can implement several interfaces
interfaces are essentially abstract classes and can have methods without impementation and static variables
interface Printable {
  • void print();
  • void print(String str);
}
class Cookie implements Printable {
  • void print() {
    • System.out.println("Cookie");
  • }
}
class WastePaper implements Printable {
  • void print(String str) {
    • int i,len=str.length();
    • for(i=0; i < len; i++) {
    • singlechar = str.charAt(i);
    • System.out.println("This is character No." + i + " " + singlechar);
    • }
  • }
}



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 Tue Feb 18 1997