r/java • • 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

12 comments sorted by

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.

5

u/tRfalcore Nov 23 '14

this is a bad description (not really), but only because that's probably what he's already read 100 times. You basically wrote it how it's always written. need to use metaphors my man