Java, Design Patterns, Structural Design Pattern, Software Engineering.
root.addComponent(folder2); folder1.addComponent(file1); folder2.addComponent(file2); root.printName(); } } When to Use the Composite Pattern Use the Composite Pattern when you need to represent part-whole hierarchies, where individual objects and compositions of objects are treated uniformly. Use