I sometimes used hash tables in several languages, but I just stumbled upon a Java map while looking at some code. I checked the differences in this SO question , which expressed this very clearly. My question is this:
When anyone can work for you, which is better to use? Which one to choose if you are not working with zeros / threads ...?
Which one is more commonly used / is more standard?
HashMap
Hashtable
Hashtable . JDK 1.0. 1.2, , Hashtable , . , ββ ( , , YMMV).
, , Hashtable, . , HashMap . , "null null" .
StringBuffer, StringBuilder.
, : HashMap: . Hashtable - . , Hashtable Collections.synchronizedMap().
HashMap, .
HashMap, Hashtable , , .
Hashtable Java, HashMap Framework Collections, Java 2. :
Hashtable , HashMap - . , .
a HashMap , Hashtable - .
a HashMapallows zero values ββin it, but Hashtablenot.
So you can go with HashMapfor any new code. If you need synchronization, you better off Collections.synchronizedMap(HashMap). See this similar SO threa d for more ideas.
Collections.synchronizedMap(HashMap)
HashMap for local variables or method parameters, since they are thread safe.
Source: https://habr.com/ru/post/1732910/More articles:PHP affected lines = 1 will not work properly - phpUsed FileStream - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1732907/get-divs-to-behave-like-a-table&usg=ALkJrhgVs7O3HecgfzlzpLvlxo43Qz3cogDistributing sharepoint default.master? - sharepointWhy does the Moose role application with method modifiers not work in my code? - perlPassing utf-8 strings between php and javascript - javascriptHow to display dependency conflicts in 'mvn site' - maven-2The default column value based on the value of another column - sqlC ++ - What libraries or command line programs will I need to create a program that takes an AVI file and burns it to a DVD? - c ++How can I make a rich web application in Perl? - user-interfaceAll Articles