Generic InternPool in Java?

后端 未结 6 1155
天涯浪人
天涯浪人 2021-01-12 01:04

How would I write a generic InternPool in Java? Does it need a Internable interface?

String in Java has interning cap

6条回答
  •  隐瞒了意图╮
    2021-01-12 01:35

    Shouldnt

    "WeakReference ref = pool.get(object);"

    instead be

    WeakReference ref = pool.intern(object);

    ??

提交回复
热议问题