Java interface
An interface in Java is an abstract type that defines a set of method signatures. It provides a way to define the agreement between classes, that is, which methods the class should implement. In this tutorial, we will explore the use and implementation of interfaces in Java.
Step 1: Define the interface
We first need to define an interface. Interfaces interface
are declared using keywords and define the methods that need to be implemented.
public interface Shape {
double getArea();
double getPerimeter();
}
In the example above, we defined a class namedShape