[Java] Difference between Hashmap and HashTable

  1. Difference in inheritance HashMap image.png

HashTable

image.png

HashTable extends Dictionary The HashTable parent class dictionary is no longer used here. image.png

  1. Difference between null keys Null key and null value cannot be used in HashTable.

It can be used with HashMap.

  1. Difference in multi-thread support All IFs in HashTable have been added synchronized, so they can operate in a multi-threaded environment as they are. image.png

HashMap can cause a deadlock when used in multiple threads. *: To avoid this, ConcurrentHashMap was added from java1.5, multithreading Can be used in the environment.

4, difference in speed HashMap is fast HashTable is slow

Summary In general, you should use HashMap, but for multithreading, use ConcurrentHashMap.

https://github.com/YanHengGo/java/tree/master/03_hashmap

Recommended Posts

[Java] Difference between Hashmap and HashTable
[Java] Difference between == and equals
[JAVA] Difference between abstract and interface
[Java] Difference between array and ArrayList
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
Difference between final and Immutable in Java
[For beginners] Difference between Java and Kotlin
[Java] Difference between Intstream range and rangeClosed
Difference between int and Integer in Java
HashMap # putAll () behaves differently between Java 7 and Java 8
Difference between vh and%
Difference between i ++ and ++ i
[Java] Understand the difference between List and Set
Difference between next () and nextLine () in Java Scanner
[Java] Difference between "final variable" and "immutable object"
Difference between product and variant
Difference between redirect_to and render
Rails: Difference between resources and resources
Difference between puts and print
Difference between redirect_to and render
Difference between CUI and GUI
Difference between variables and instance variables
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
Difference between ArrayList and LinkedList
Difference between render and redirect_to
Difference between List and ArrayList
java Generics T and? Difference
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
[Java] Difference between static final and final in member variables
[JAVA] What is the difference between interface and abstract? ?? ??
What is the difference between Java EE and Jakarta EE?
[Java beginner] Difference between length and length () ~ I don't know ~
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between render method and redirect_to
Difference between interface and abstract class
Difference between == operator and equals method
Differences between "beginner" Java and Kotlin
[Terminal] Difference between irb and pry
JavaServlet: Difference between executeQuery and executeUpdate
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Difference between Java and JavaScript (how to find the average)
Rough difference between RSpec and minitest
[Rails] Difference between find and find_by
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
[Java] Relationship between H2DB and JDBC
Difference between Thymeleaf @RestController and @Controller
Difference between Stream map and flatMap
[Java] Difference between assignment of basic type variable and assignment of reference type variable
[Java] Check the difference between orElse and orElseGet with IntStream
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())