When you define a new interface, you are defining a new reference data type. You can use interface names anywhere you can use any other data type name. If you define a reference variable whose type is an interface, any object you assign to it must be an instance of a class that implements the interface.
Basic Design Principle : “Program to an interface rather than to an implementation“. In very simple terms, this helps us to change the data structures easily in future without much modifications. Programming to an interface is saying, “I need this functionality and I don’t care where it comes from“. Suppose today, you use one implementation of a list, let’s say ArrayList. Tomorrow, you may realize that you need to use LinkedList. If you had programmed to an interface, it’s just one line change, because everywhere in your code you are using the interface reference variable. On the other hand, if you had programmed to an implementation, you need to change all the references to that variable.
Using interfaces is a key factor in making your code easily testable in addition to removing unnecessary couplings between your classes. By creating an interface that defines the operations on your class, you allow classes that want to use that functionality the ability to use it without depending on your implementing class directly. If later on you decide to change and use a different implementation, you need only change the part of the code where the implementation is instantiated. The rest of the code need not change because it depends on the interface, not the implementing class.