As far as I understand, the purpose of a Bridge pattern is, quoting from Wikipedia, “to decouple an abstraction from its implementation”. Well isn’t that exactly what an interface does. By deciding on an interface and forcing a class to use that interface, any other class can interact with this one without the need for any knowledge about the internal workings.
So is an interface equivalent to a Bridge?
Interface just means “public API” of something: That is the contract against which you write software. Java uses the keyword
interfaceto define classes without code that contain such contracts.The bridge pattern is a design pattern. It stands for decoupling. You could say Java interfaces are one way to implement this pattern.
Note that bridges usually expose the full API while Java interfaces can expose only part of the API. Example: You have a class
Foowith two methods:bar()andbaz().A bridge is anything which has the same public API as
Fooand which can be used in any place whereFoocan be used.With interfaces, you can have two. One contains
bar()and the otherbaz(). Any class which implements both is a valid implementation forFoobut you can also have classes which implement only one of them.