@@ -0,0 +1,906 @@
+// --------------------- %E4%BA%AB%E5%85%83%E7%B1%BB%0A%0Apublic class Flyweight %7B%0A    private String name = %22%22;%0A%0A    public Flyweight(String name) %7B%0A        this.name = name;%0A    %7D%0A%0A    public void hello() %7B%0A        System.out.println(%22hello %22 + name);%0A    %7D%0A%7D%0A%0A// --------------------- %E4%BA%AB%E5%85%83%E5%B7%A5%E5%8E%82%0A%0Apublic class FlyweightFactory %7B%0A    HashMap%3CString, Flyweight%3E pool = new HashMap%3CString, Flyweight%3E();%0A%0A    public Flyweight getFlyWeight(String name) %7B%0A        Flyweight flyweight = null;%0A%0A        if (pool.containsKey(name)) %7B%0A            flyweight = pool.get(name);%0A        %7D%0A        else %7B%0A            flyweight = new Flyweight(name);%0A            pool.put(name, flyweight);%0A        %7D%0A%0A        return flyweight;%0A    %7D%0A%7D%0A%0A// --------------------- test code%0A%0Apublic static void main(String%5B%5D args) %7B%0A    FlyweightFactory factory = new FlyweightFactory();%0A    Flyweight flyweight = factory.getFlyWeight(%22luoxn28%22);%0A%0A    flyweight.hello();%0A%7D

add flyweight pattern