Basic HTML version of Foils prepared May 12 1996

Foil 65 Java Language -- Interfaces

From CRPC Lectures on Java Language Applets Graphics CRPC Annual Meeting Tutorial -- May 14,1996. by Geoffrey C. Fox


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 Sun Dec 14 1997