map vs hashmap java code example
Example 1: java foreach map
map.forEach((k, v) -> System.out.printf( " %s : %d \n" , k,v) );
Example 2: 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