Why is the 't' in Hash Table(Hashtable) in Java not capitalized [closed]

心已入冬 提交于 2019-11-27 03:28:44

问题


Everything in Java seems to follow capitalization rules except for Hashtable.

Hashtable<String, String> ht = new Hashtable<String, String>();

as opposed to

ArrayList<String> a = new ArrayList<String>();

or

HashMap<String,Integer> a = new HashMap<String,Integer>(); 

Why is this ? Is Hash Table read as just one word (Hashtable) ?


回答1:


Hashtable was created in Java v1. The consistent naming conventions for collections were established later, in Java2, when the other classes were published as part of the brand new Java Collection Framework.

Which btw made Hashtable obsolete, so it should not be used in new code.

Hope that helps.




回答2:


Although this question has no technical value, I have to admit, I've asked myself this a couple of times :)

My version is that unlike List (ArrayList), Set (HashSet) , Map (Tree/HashMap) table is not a data structure.

Of course (its possibly known) that the Hashtable class was created before the collection framework (in java 1.0). So maybe at that point they didn't really thought about the same naming conventions. In general we better use collection framework from java 2+ :)



来源:https://stackoverflow.com/questions/12506706/why-is-the-t-in-hash-tablehashtable-in-java-not-capitalized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!