How does Java – weakhashmap work?

When would you use a weakhashmap or a WeakReference? 10

Solution

You can't use string text in weakhashmap (you can, but it doesn't make sense):

String myKey = "somekey";

Instead, you must use:

String myKey = new String("somekey");

In the latter case, strings are not merged

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>