interface

 

  interface is one of the only three statements that can appear with no modifiers.   The others are class and constructors.  Methods cannot appear with no modifiers (they need a return type or void).  Nor can variables (they need a type).

 

  You cannot put constructors in an interface.

 

  You must label all methods in an interface to be abstract or make them abstract-like. (As opposed to a class, which can be labeled abstract without actually having any abstract methods.)

 

  The actual abstract modifier on an interface's methods is optional.  i.e.

 

public abstract void method1( );  and 

public void method1( );  both create abstract methods.

 

  All variables in an interface must be final.  They can be static final.  Meaning they must be constants.

 

  An interface can extend another interface. You cannot "implement" another interface.  i.e. The class Demo below must implement all four methods of One and Two or be abstract itself:

 

interface One {

public abstract void method1( );

public void method2( ); 

 }

 

interface Two extends One {

public abstract void method3( );

public void method4( ); 

 }

 

public class Demo implements Two {

public void method1( ) {  }

public void method2( ) {  }

public void method3( ) {  }

public void method4( ) {  }  

}

 

  There is no “base” interface, serving like Object does for classes.