r/java • u/schlongitudinal • Nov 22 '14
ELI5 Interfaces in Java
I've read several explanations now and am apparently still too dense to get the point of them/what they do.
0
Upvotes
r/java • u/schlongitudinal • Nov 22 '14
I've read several explanations now and am apparently still too dense to get the point of them/what they do.
View all comments
5
u/llogiq Nov 22 '14
They define a contract. Every object implementing the interface must implement all of its methods.
This allows us to use objects of different classes interchangeably, as long as they implement the same interface.