definition of interface in java code example

Example 1: interface in java

/* File name : Animal.java */
interface Animal {
   public void eat();
   public void travel();
}

Example 2: java interface

public interface Exampleinterface {
	
  public void menthod1();
  
  public int method2();

}

class ExampleInterfaceImpl implements ExampleInterface {


  	public void method1()
    {
        //code here
    }
  
    public int method2()
  	{
    	//code here
  	}

}

Example 3: interface base1 void method();

interface Base

Tags:

Misc Example