
Composition Design Pattern in Java with Real-World Examples
Composition is a design principle that favors “has-a” relationships over “is-a” relationships (inheritance). Instead of extending functionality through subclassing, composition achieves it by containing instances of other classes that implement the desired functionality.