Interface




An Interface is a list of public abstract methods and public static final constants. A class that implements the interface must implement all of the listed methods.

Example:


public interface Shape
{
   public static final int lineWidth = 1;
      
   public abstract int getX();
   public abstract void setX(int x);
   public abstract int getY();
   public abstract void setY(int y);
   public abstract int getWidth();
   public abstract void setWidth(int width);
   public abstract int getHeight();
   public abstract void setHeight(int height);
}


public class Rectangle implements Shape
{

   // you must write all of the methods listed in the interface
   
   public int getX()
   {
       return x;
   }

   etc.
   
}


Note:  You can leave off the public abstract for methods.
       Methods are public abstract by default in an interface.
	   
       You can also leave off the public static final for constants.
       Constants defined in an interface are public static final by default
       in an interface.