通用InternPool T在Java中? [英] Generic InternPool<T> in Java?
本文介绍了通用InternPool T在Java中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何用Java编写通用的InternPool<T>
?是否需要Internable
接口?
How would I write a generic InternPool<T>
in Java? Does it need a Internable
interface?
String
具有实习功能;我想实习像BigDecimal
和Account
这样的类.
String
in Java has interning capabilities; I want to intern classes like BigDecimal
and Account
.
推荐答案
例如,请查看Internable
接口,它仅依赖于equals
和hashCode
.
For an example take a look at Interner
from Guava. It does not require an Internable
interface, it just relies on equals
and hashCode
.
这篇关于通用InternPool T在Java中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文