{"id":122,"date":"2026-06-03T04:46:17","date_gmt":"2026-06-03T04:46:17","guid":{"rendered":"https:\/\/gigz.pk\/javaapp\/?post_type=lesson&#038;p=122"},"modified":"2026-06-06T07:47:02","modified_gmt":"2026-06-06T07:47:02","slug":"hashmap","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/javaapp\/?lesson=hashmap","title":{"rendered":"HashMap"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">HashMap is one of the most powerful and widely used classes in the Java Collections Framework. It stores data in <strong>key-value pairs<\/strong>, allowing fast retrieval, insertion, and deletion of information. Unlike arrays and ArrayLists that use indexes, HashMap uses unique keys to access values.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap is commonly used in Java applications, Android development, web systems, database-driven applications, and enterprise software where efficient data storage and retrieval are required.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is HashMap in Java?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap is a collection class that stores data in key-value pairs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each entry in a HashMap consists of:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Key<\/li>\n\n\n\n<li>Value<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Name \u2192 Ali\nAge \u2192 25\nCity \u2192 Lahore\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Name, Age, and City are keys<\/li>\n\n\n\n<li>Ali, 25, and Lahore are values<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A key is used to access its corresponding value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap belongs to the:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java.util\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">package.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use HashMap?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap provides several advantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fast data retrieval<\/li>\n\n\n\n<li>Efficient searching<\/li>\n\n\n\n<li>Dynamic storage<\/li>\n\n\n\n<li>Easy insertion and deletion<\/li>\n\n\n\n<li>Stores related information together<\/li>\n\n\n\n<li>Supports large datasets<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is one of the most frequently used data structures in Java programming.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importing HashMap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before using HashMap, import the class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.HashMap;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This provides access to all HashMap functionality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a HashMap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A HashMap is created using the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;KeyType, ValueType&gt; map = new HashMap&lt;&gt;();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This HashMap stores String keys and String values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding Elements to HashMap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>put()<\/code> method adds key-value pairs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\nstudents.put(\"S02\", \"Ahmed\");\nstudents.put(\"S03\", \"Sara\");\n\nSystem.out.println(students);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{S01=Ali, S02=Ahmed, S03=Sara}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each key must be unique.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Accessing Values<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>get()<\/code> method retrieves a value using its key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\n\nSystem.out.println(students.get(\"S01\"));\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ali\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The key is used to access its associated value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Updating Values<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If an existing key is used again, the value is updated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\n\nstudents.put(\"S01\", \"Ahmed\");\n\nSystem.out.println(students);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{S01=Ahmed}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The old value is replaced by the new value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Removing Elements<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>remove()<\/code> method deletes a key-value pair.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\nstudents.put(\"S02\", \"Sara\");\n\nstudents.remove(\"S01\");\n\nSystem.out.println(students);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{S02=Sara}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The specified key and its value are removed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checking if a Key Exists<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>containsKey()<\/code> method checks whether a key exists.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\n\nSystem.out.println(students.containsKey(\"S01\"));\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>true\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This method is useful for validation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checking if a Value Exists<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>containsValue()<\/code> method checks whether a value exists.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\n\nSystem.out.println(students.containsValue(\"Ali\"));\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>true\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This helps search for specific values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Finding the Size of HashMap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>size()<\/code> method returns the number of entries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\nstudents.put(\"S02\", \"Sara\");\n\nSystem.out.println(students.size());\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The size indicates how many key-value pairs are stored.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Clearing All Entries<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>clear()<\/code> method removes all data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\n\nstudents.clear();\n\nSystem.out.println(students);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The HashMap becomes empty.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Iterating Through a HashMap<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Displaying Keys<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(\"S01\", \"Ali\");\nstudents.put(\"S02\", \"Sara\");\n\nfor (String key : students.keySet()) {\n\n    System.out.println(key);\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>S01\nS02\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Displaying Values<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (String value : students.values()) {\n\n    System.out.println(value);\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ali\nSara\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Displaying Keys and Values<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (String key : students.keySet()) {\n\n    System.out.println(key + \" : \" + students.get(key));\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>S01 : Ali\nS02 : Sara\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This approach is commonly used in real applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">HashMap with Different Data Types<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Integer Keys<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;Integer, String&gt; students = new HashMap&lt;&gt;();\n\nstudents.put(1, \"Ali\");\nstudents.put(2, \"Sara\");\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">String and Integer<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>HashMap&lt;String, Integer&gt; marks = new HashMap&lt;&gt;();\n\nmarks.put(\"Ali\", 90);\nmarks.put(\"Sara\", 85);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap supports various data type combinations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Complete Example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.HashMap;\n\npublic class Main {\n\n    public static void main(String&#91;] args) {\n\n        HashMap&lt;String, Integer&gt; marks = new HashMap&lt;&gt;();\n\n        marks.put(\"Ali\", 90);\n        marks.put(\"Ahmed\", 85);\n        marks.put(\"Sara\", 95);\n\n        System.out.println(\"Ali Marks: \" + marks.get(\"Ali\"));\n\n        for (String student : marks.keySet()) {\n\n            System.out.println(student + \" = \" + marks.get(student));\n\n        }\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ali Marks: 90\nAli = 90\nAhmed = 85\nSara = 95\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This example demonstrates practical HashMap usage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How HashMap Works Internally<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap stores data using a hashing mechanism.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a key is added:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Java generates a hash code for the key.<\/li>\n\n\n\n<li>The hash code determines where the value will be stored.<\/li>\n\n\n\n<li>The value is stored in a bucket.<\/li>\n\n\n\n<li>Retrieval uses the same hash code to locate the data quickly.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This process makes HashMap extremely fast for searching and retrieval operations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Important Features of HashMap<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Unique Keys<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Duplicate keys are not allowed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>map.put(\"A\", 100);\nmap.put(\"A\", 200);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{A=200}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The second value replaces the first.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Duplicate Values Allowed<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>map.put(\"A\", 100);\nmap.put(\"B\", 100);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is valid because values can repeat.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Allows One Null Key<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>map.put(null, \"Java\");\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap allows one null key.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Allows Multiple Null Values<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>map.put(\"A\", null);\nmap.put(\"B\", null);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Multiple null values are permitted.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Real-World Applications of HashMap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap is widely used in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Student management systems<\/li>\n\n\n\n<li>Banking applications<\/li>\n\n\n\n<li>User authentication systems<\/li>\n\n\n\n<li>Android applications<\/li>\n\n\n\n<li>E-commerce platforms<\/li>\n\n\n\n<li>Inventory management systems<\/li>\n\n\n\n<li>Online booking systems<\/li>\n\n\n\n<li>Database-driven applications<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Many enterprise systems rely heavily on HashMap for fast data access.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Beginner Mistakes<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Duplicate Key Confusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using the same key replaces the old value.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Forgetting Import Statement<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.HashMap;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">must be included.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Accessing Non-Existing Keys<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>System.out.println(map.get(\"Unknown\"));\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>null\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Developers should check if a key exists before retrieving its value.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mixing Incorrect Data Types<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The key and value types must match the HashMap declaration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When using HashMap:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use meaningful keys<\/li>\n\n\n\n<li>Check keys before retrieval<\/li>\n\n\n\n<li>Avoid unnecessary null values<\/li>\n\n\n\n<li>Use generics for type safety<\/li>\n\n\n\n<li>Keep keys unique<\/li>\n\n\n\n<li>Use proper iteration methods<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These practices improve code quality and maintainability.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importance of HashMap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap is important because it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Provides fast data retrieval<\/li>\n\n\n\n<li>Stores related information efficiently<\/li>\n\n\n\n<li>Supports dynamic data management<\/li>\n\n\n\n<li>Improves application performance<\/li>\n\n\n\n<li>Simplifies complex data handling<\/li>\n\n\n\n<li>Forms the foundation of many Java applications<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is one of the most essential data structures for Java developers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HashMap is a powerful collection class in Java that stores data as key-value pairs and provides fast access to information. With features such as dynamic storage, efficient searching, unique keys, and flexible data handling, HashMap is widely used in Java, Android, web, and enterprise application development. Mastering HashMap is an important step toward becoming a professional Java developer and building efficient, scalable software solutions.<\/p>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1780732056527\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/javaapp\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Intermediate Java > Strings and Collections > HashMap<\/span><\/span><\/div>","protected":false},"menu_order":34,"template":"","class_list":["post-122","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>HashMap - Learn Java used for Apps with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn Java HashMap \u2014 how to add, access, update, remove, and iterate key-value pairs with examples and real-world applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HashMap - Learn Java used for Apps with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn Java HashMap \u2014 how to add, access, update, remove, and iterate key-value pairs with examples and real-world applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Java used for Apps with GiGz.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-06T07:47:02+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/?lesson=hashmap\",\"url\":\"https:\\\/\\\/gigz.pk\\\/\",\"name\":\"HashMap - Learn Java used for Apps with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/#website\"},\"datePublished\":\"2026-06-03T04:46:17+00:00\",\"dateModified\":\"2026-06-06T07:47:02+00:00\",\"description\":\"Learn Java HashMap \u2014 how to add, access, update, remove, and iterate key-value pairs with examples and real-world applications.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/javaapp\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Intermediate Java > Strings and Collections > HashMap\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/\",\"name\":\"Learn Java used for Apps with GiGz.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HashMap - Learn Java used for Apps with GiGz.PK","description":"Learn Java HashMap \u2014 how to add, access, update, remove, and iterate key-value pairs with examples and real-world applications.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/","og_locale":"en_US","og_type":"article","og_title":"HashMap - Learn Java used for Apps with GiGz.PK","og_description":"Learn Java HashMap \u2014 how to add, access, update, remove, and iterate key-value pairs with examples and real-world applications.","og_url":"https:\/\/gigz.pk\/","og_site_name":"Learn Java used for Apps with GiGz.PK","article_modified_time":"2026-06-06T07:47:02+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/javaapp\/?lesson=hashmap","url":"https:\/\/gigz.pk\/","name":"HashMap - Learn Java used for Apps with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/javaapp\/#website"},"datePublished":"2026-06-03T04:46:17+00:00","dateModified":"2026-06-06T07:47:02+00:00","description":"Learn Java HashMap \u2014 how to add, access, update, remove, and iterate key-value pairs with examples and real-world applications.","breadcrumb":{"@id":"https:\/\/gigz.pk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/javaapp"},{"@type":"ListItem","position":2,"name":"Intermediate Java > Strings and Collections > HashMap"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/javaapp\/#website","url":"https:\/\/gigz.pk\/javaapp\/","name":"Learn Java used for Apps with GiGz.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/javaapp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=\/wp\/v2\/lesson\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}