Difference between HasMap and LinkedHashMap in java
HashMap and LinkedHashMap are the two most commonly used Map interface in java. Both are not synchronized.
Here is the basic difference between HashMap and LinkedHashMap.
- HashMap doesn't maintains the order, while the LinkedHashMap maintains the order of insertion.
- LinkedHahMap consumes more memory than LinkedHashMap.
- LinkedHashMap implement Map interface but extends HashMap.
Here are some of the similarities between these.
- Both are subject to race condition because both are not synchronized.
- Both are fail-fast.
No comments:
Post a Comment