Java – Interface Example

Java interface example

This example will explain how to implement interface in java

Interface

JavaInterface.java

/**
 * This is interface which can implement in java class
 */
public interface JavaInterface {

    public void add();

    public void delete();

    public void find();

    public void edit();

}

class which implementing interface

JavaClassInterfaceExample.java

public class JavaClassInterfaceExample implements JavaInterface{

    public void add()
    {
        // statements
        System.out.println("add method implement by interface");
    }

    public void edit()
    {
        // statements
    }

    public void find()
    {
        // statements
    }

    public void delete()
    {
        // statements
    }

    public static void main(String args[])
    {
        JavaClassInterfaceExample jie = new JavaClassInterfaceExample();
        jie.add();
    }
}

Output

add method implement by interface

Tags:

Bookmark  

 

Leave a Reply

Security Code:

 

  Random Post