difference between hashmap and hashset in java code example

Example 1: difference between hashmap and map java

Hash map: 

	-> It is the implementation of map interface.
	-> It can contain null values and keys.
	-> It doesn't maintain input order.

Map: 

	-> It is an interface
	-> Map has two implementation
	-> Tree Map
	-> Hash Map
	-> Tree Map maintains the input order .
	-> It will not allow any null values.
	-> Duplicate keys are not allowed in the map

Example 2: Difference between HashMap and HashTable

1) HashTable is thread-safe/synchronized
HashMap is not thread safe and faster
2) HashTable does not allow any null key
HashMap allows one null key
3) Both of them implement Map interface.

Tags:

Java Example