This is a @structural design pattern takes the memory foot print ( weight ) from the objects by recycling them.
The common parts of the state are shared between the objects instead of storing data in each individual object.
The Flyweight objects are made as immutable.
Implementation
- Using a Map for storing the created objects associated with a key and provide the object when requested from the map.
- We could also create a factory class to manage flyweight objects.