Interface In Java Programming – An Example

An interface in java is a collection of abstract methods and constant identifiers. There are no defined methods and  no fields. From that definition, if a class provides method definitions for an interface’s methods, the class is said to implement the interface. The class may also define other methods. In this post, we will see how to use an interface in java.

interface in java

The Example – An Interface In Java

In this example, we will create an interface called Employee for all the employees in a company. The information read in for each employee in question consists of employee’s name and gross pay. So, we need to list the responsibilities of the interface that will help us define the methods’ specifications. In other words, the responsibilities means the services provided to users of any class that implements the Employee interface. So here they are: