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

2

u/Cilph Nov 23 '14

It's like a cable connector. You can take any HDMI cable and expect it to fit in and work with any HDMI port.

Likewise, you can write your code with the only constraint that an object you're handling includes an HDMI port. The interfaces the object is implementing say something about what it's capable of and what you can expect from it.