LruCache
is a map, but I want to use LruCache
to only cache strings, i.e. I want LruCache to work as a HashSet.
How should I define a LruCache
class?
LruCache<String, Void>
won't work, because when my code called lruCache.put("abc", null)
, NullPointerException
was thrown.
Thanks.
The docs are pretty clear:
You can define your own string wrapper class to use for values. You can have a special instance of it to represent null strings.
Then you can store a non-null null: