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


1 A class can only have one parent class but can implement several interfaces
2 interfaces are essentially abstract classes and can have methods without impementation and static variables
3 interface Printable {
  • void print();
  • void print(String str);
4 }
5 class Cookie implements Printable {
  • void print() {
    • System.out.println("Cookie");
  • }
6 }
7 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);
    • }
  • }
8 }

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