Java Interfaces
An interface is a collection of methods that have no implementation - they are just created, but have no functionality. An interface is a bit like a class, except you can only declare methods and variables in the interface. You cannot actually implement the methods.
Declaring an interface
While Java provides interfaces for you to use, you can also create your own.
An interface is declared with the interface keyword.
Syntax
interface nameOfInterface{
//methods for interface here;
}
Ads by Google


Java Interface Example
interface IntExample{

public void sayHello();
}
}

public class JavaInterfaceExample implements IntExample{
public void sayHello(){
System.out.println("Hello Visitor !");
}
public static void main(String args[]){

JavaInterfaceExample javaInterfaceExample = new JavaInterfaceExample();
javaInterfaceExample.sayHello();
}
}
Output
Hello Visitor !
Previous - Java Encapsulation                                                         Next - Java Packages