HashMap is one of the most used data structures in Java — it’s fast, efficient, and ideal for key-value lookups.…