Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Map Interface

Lesson 33 of 39 in the free Java notes on Siksha Sarovar, written by Rohit Jangra.

Map Interface

Map is NOT a child of Collection Interface. It stores data in Key-Value pairs. Key Features:

  1. Key: Must be Unique. If duplicated, old value is replaced.
  2. Value: Can be duplicated.
  3. Association: Each key maps to one value.

Implementation Classes

  1. HashMap
  2. LinkedHashMap
  3. TreeMap
  4. Hashtable (Legacy)

1. HashMap

Order: Random. • Synchronization: Not synchronized. • Null: 1 null key allowed, multiple null values. • Working: Uses Hashing (Bucket, HashCode, Equals).

2. LinkedHashMap

Order: Insertion Order preserved. • Performance: Slightly slower due to linking overhead.

3. TreeMap

Order: Sorted Order based on Keys. • Null: No null keys allows.

4. Hashtable

Legacy: Since JDK 1.0. • Synchronization: Thread-safe (All methods are synchronized). • Null: No null key or value allowed. • Performance: Slow.

Iterating a Map

Map is not Iterable directly. We convert it to Set/Collection:

  1. keySet(): Returns Set of keys.
  2. values(): Returns Collection of values.
  3. entrySet(): Returns Set of Entry (Key-Value pairs).