What are interfaces?
I have been programming in java since 2014. Mostly I have written applications that run on android system. From very first day I knew there is something named ‘interfaces’ that can be used to follow an important property of ‘inheritance’ and it’s definition was
An interface is a reference type in Java, it is similar to class, it is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.
Then as time passed I knew more about interfaces
- Java doesn’t have multiple inheritance. To make it possible makers introduced interfaces into the recipe.
- ‘polymorphism’ that is hard to explain is again can be achieved using interfaces.
and many other application of interfaces like it gives a brief introduction of the class which is implementing it.
But still one question in my mind why to redeclare a function again in the class which implements an interface ?(Duplication)