用Java替换过时的Hashtable类 [英] Replacement for obsolete Hashtable class in Java

查看:488
本文介绍了用Java替换过时的Hashtable类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用散列表类时,Netbeans给了我一个错误说:

When I tried to use the hashtable class, Netbeans gave me an error saying:


虽然仍然支持,但这些类已经过时了由JDK1.2集合类,并且可能不应该在新开发中使用。

While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development.

然而,我似乎无法找到更好地替换 Hashtable 的在线示例。有什么建议吗?

However, I can't seem to find an example online on a better replacement for Hashtable. Any suggestions?

推荐答案

Hashtable HashMap

可能重要的一个区别是 Hashtable 的所有相关方法都是同步的它们在 HashMap 同步。

One difference that could be important is that all relevant methods of Hashtable are synchronized while they are not synchronized on HashMap.

这篇关于用Java替换过时的Hashtable类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆