Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

代码结构

- src
  - Flyweight.java # 定义抽象享元接口
  - ConcreteFlyweight.java # 具体享元角色,实现抽象接口,用于共享状态
  - UnsharedConcreteFlyweight.java # 无需共享的角色,实现抽象接口,每次都是新实例
  - FlyweightFactory.java # 享元工厂,储存一个对象共享池

测试验证

$ cd ./flyweight-pattern/java
$ javac test/Test.java
$ java test/Test