设计模式结构型模式 设计模式 2018-06-01 享元模式定义享元模式(Flyweight Pattern):减少创建对象的数量,以减少内存占用和提高性能。类图角色Flyweight: 抽象享元类ConcreteFlyweight: 具体享元类UnsharedConcreteFlyweight: 非共享具体享元类FlyweightFactory: 享元工厂类使用场景Java中的字符串池Integer对象,当值在-128~+128时,返回的是缓存对象参考https://refactoringguru.cn/design-patterns/flyweighthttps://test-design-patterns.readthedocs.io/zh/latest/structural_patterns/flyweight.html