previous | start | next

Interface Types

.

Java Interface Example

Interface definition in file Comparable.java:
/**
 Interface for comparing with another Message object.
 */
public interface Comparable {
    /**
      compare this with another message.
      @param msg the other message
      @return -1 if this message is older than msg, 0 if this.equals(msg), 
and +1 if this message is more recent than msg. */ public int compareMessage(Message msg); };
Class Message implements this interface (in file Message.java):
public class Message implements Comparable {
    ....
    public int compareMessage(Message msg)
    {
        // method implementation body
    }
    ....
};

previous | start | next