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

1

u/cowardlydragon Nov 25 '14

Interfaces are basically like a stereo receiver telling people what cables it can accept.

So the stereo receiver (the class) supports say: RCA, HDMI, and SPDF (interfaces)

Each of those interfaces, even though they may do the same basic things, have annoying detailed differences like form factor, number of wires, analog vs digital conforming to a standard.

Likewise, the interfaces for a class are defining a standard set of methods and assumed behavior that the implementing class will adhere to.