I’m looking here at a summary of “interfaces” in Java: http://docs.oracle.com/javase/tutorial/java/IandI/summary-interface.html
The first line states, “An interface defines a protocol of communication between two objects.”
Is that really accurate? From my understanding, an interface is just a contract promising to offer some set of members/methods, which could be used by any arbitrary number of clients (so long as they have proper access per the access modifiers). Am I missing some “other side” of the contract which would make an interface “between two objects”?
EDIT: From the answers/comments (and the votes to close! :-[ ), I think I have it figured out. I think I was just getting hooked on the “between two objects” and assuming it meant “between ONLY two objects”, which was apparently a wrong assumption. Thanks!
Whenever you use an object you use it always from another object. You don’t call a method from more than an object at the same time.
So if A offers an interface, then B relies on it and C too but A is still offering an interface to B and C separately.