{"id":13375,"date":"2020-03-16T04:05:33","date_gmt":"2020-03-16T11:05:33","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13375"},"modified":"2023-12-01T02:31:57","modified_gmt":"2023-12-01T10:31:57","slug":"java-hashmap","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-hashmap\/","title":{"rendered":"How to Use the Java HashMap Class"},"content":{"rendered":"\n<p>In programming, data types are used to classify particular types of data. Each data type is stored in a different way, and the data type in which a value is stored will determine the operations which can be performed on the value.<br><\/p>\n\n\n\n<p>When you\u2019re working in Java, one class you may encounter is the Java HashMap class. This class is part of the collections framework and allows developers to store data using the Map data type.<br><\/p>\n\n\n\n<p>This tutorial will discuss the basics of Java HashMaps, how to create a HashMap, and explore the main methods which can be used when working with the HashMap class. This article will refer to examples throughout so that we can explain the HashMap class in more depth.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Maps and HashMap<\/h2>\n\n\n\n<p>The Java Map interface is used to store Map values in a key\/value pair. Keys are unique values that are associated with a specific value. In Java, a map cannot contain duplicate keys, and each key must be associated with a particular value.<br><\/p>\n\n\n\n<p>The key\/value structure offered by Map allows you to access values based on their keys. So, if you had a map with the key <code>gbp<\/code> and the value <code>United Kingdom<\/code>, when you reference the key <code>gbp<\/code> the value \u201cUnited Kingdom\u201d will be returned.<br><\/p>\n\n\n\n<p>The HashMap class is part of the collections framework and allows you to store data using the Map interface and hash tables. Hash tables are special collections used to store key\/value items.&nbsp;<br><\/p>\n\n\n\n<p>Before we can create a HashMap, we must first import the HashMap package. Here\u2019s how we can do that in a Java program:<br><\/p>\n\n\n\n<p><code>import java.util.hashmap;<br><\/code><\/p>\n\n\n\n<p>Now that we have imported the HashMap package, we can start creating HashMaps in Java.&nbsp;<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a HashMap<\/h2>\n\n\n\n<p>To create a HashMap in Java, we can use the following syntax:<br><\/p>\n\n\n\n<p><code>HashMap&lt;KeyType, ValueType&gt; map_name = new HashMap&lt;KeyType, ValueType&gt;(capacity, loadFactor);<br><\/code><\/p>\n\n\n\n<p>Let\u2019s break this down into its basic components:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>HashMap<\/strong> is used to tell our code that we are declaring a hashmap.<\/li>\n\n\n\n<li><strong>&lt;KeyType, ValueType&gt;<\/strong> stores the data types for the keys and values, respectively.<\/li>\n\n\n\n<li><strong>map_name<\/strong> is the name of the hashmap we have declared.<\/li>\n\n\n\n<li><strong>new HashMap&lt;KeyType, ValueType&gt;<\/strong> tells our code to initialize a HashMap with the data types we have specified.<\/li>\n\n\n\n<li><strong>capacity<\/strong> tells our code how many entries it can store. By default, this is set to 16. (optional)<\/li>\n\n\n\n<li><strong>loadFactor<\/strong> tells our code that when our hash table reaches a certain capacity, a new hash table of double the size of the original hash table should be created. By default, this is set to 0.75 (or 75% capacity). (optional)<\/li>\n<\/ul>\n\n\n\n<p>Suppose we are creating a program for a local currency exchange business. They want to create a program that stores the names of the countries and the currency codes in which they offer exchange services. Using a HashMap is a good idea to store this data because we have two items that we want to store together: country name and currency code.<br><\/p>\n\n\n\n<p>Here\u2019s the code we would use to create a HashMap for this purpose:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.HashMap;\nHashMap&lt;String, String&gt; currencyCodes = new HashMap&lt;String, String&gt;();\n<\/pre><\/div>\n\n\n\n<p>In this example, we have declared a HashMap called <code>currencyCodes<\/code> which stores two String values. Now that we have our HashMap, we can start adding items and manipulating its contents.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add Items<\/h2>\n\n\n\n<p>The HashMap class offers a wide range of methods that can be used to store and manipulate data. The put() method is used to add values to a HashMap using the key\/value structure.<br><\/p>\n\n\n\n<p>Let\u2019s go back to the currency exchange. Suppose we want to add the entry <code>GBP<\/code>\/<code>United Kingdom<\/code> into our program, which will store the currency value for the UK. The <code>GBP<\/code> key is mapped to the <code>United Kingdom<\/code> value in this example. We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.HashMap;\nclass CurrencyExchange {\n\tpublic static void main(String[] args) {\n\t\tHashMap&lt;String, String&gt; currencyCodes = new HashMap&lt;String, String&gt;();\n\t\tcurrencyCodes.put(\"GBP\", \"United Kingdom\");\ncurrencyCodes.put(\"USD\", \"United States\");\n\t\tSystem.out.println(currencyCodes);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>In our code, we initialize a hash map called <code>currencyCodes<\/code>, then we use the put() method to add an entry into the hash map. This entry has the key <code>GBP<\/code> and the value <code>United Kingdom<\/code>. Then we print out the value of the HashMap, which returns the following:<br><\/p>\n\n\n\n<p><code>{GBP=United Kingdom,USD=United States}<br><\/code><\/p>\n\n\n\n<p>As you can see, our HashMap now contains two values: GBP=United Kingdom and USD=United States.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Access an Item<\/h2>\n\n\n\n<p>To access an item in a HashMap, you can use the get() method. The <code>get<\/code> method accepts one parameter: the key name for the value you want to retrieve.<br><\/p>\n\n\n\n<p>Suppose we want to retrieve the country name associated with GBP. We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\u2026\n\t\tString gbp = currencyCodes.get(\"GBP\");\n\t\tSystem.out.println(currencyCodes);\n\u2026 \n<\/pre><\/div>\n\n\n\n<p>Our code returns: United Kingdom.<br><\/p>\n\n\n\n<p><code>Remove an Item<br><\/code><\/p>\n\n\n\n<p>The remove() method is used to remove an item from a HashMap. remove() accepts one parameter: the name of the key whose entry you want to remove.<br><\/p>\n\n\n\n<p>Suppose we want to remove <code>GBP<\/code> from our HashMap. We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\u2026\ncurrencyCodes.remove(\"GBP\");\nSystem.out.println(currencyCodes);\n\u2026\n<\/pre><\/div>\n\n\n\n<p>When we run our code, <code>GBP<\/code> is removed from our HashMap and the following response is returned: {USD=United States}<br><\/p>\n\n\n\n<p>In addition, the clear() method is used to remove all items from a HashMap. clear() accepts no parameters. Here\u2019s an example of the clear() method in action:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\u2026\ncurrencyCodes.clear();\nSystem.out.println(currencyCodes);\n\u2026\n<\/pre><\/div>\n\n\n\n<p>Our code returns an empty HashMap:<code> {}<\/code>.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Replace HashMap Elements<\/h2>\n\n\n\n<p>The replace() method is used to replace a value associated with a specific key with a new value. replace() accepts two parameters: the key of the value you want to replace, and the new value with which you want to replace the old value.<br><\/p>\n\n\n\n<p>Suppose, for instance, that we wanted to replace the value <code>United Kingdom<\/code> with <code>Great Britain<\/code> in our HashMap. We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\u2026\n\t\tcurrencyCodes.replace(\"GBP\", \"Great Britain\")\n\t\tSystem.out.print(currencyCodes);\n\u2026\n<\/pre><\/div>\n\n\n\n<p>When we execute our code, the value of the key <code>GBP<\/code> (which is <code>United Kingdom<\/code> in this case) is replaced with <code>Great Britain<\/code> and our program returns the following:<br><\/p>\n\n\n\n<p>{GBP=Great Britain,USD=United States}<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Iterate Through a HashMap<\/h2>\n\n\n\n<p>Additionally, you can iterate through a HashMap in Java. HashMap offers three methods which can be used to iterate through a HashMap:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>keySet() is used to iterate through the keys in a HashMap.<\/li>\n\n\n\n<li>values() is used to iterate through the values in a HashMap.<\/li>\n\n\n\n<li>entrySet() is used to iterate through the keys and values in a HashMap.<\/li>\n<\/ul>\n\n\n\n<p>The easiest way we can iterate through a HashMap is to use a <code>for-each<\/code> loop. If you\u2019re interested in learning more about Java for-each loops, you can read our tutorial on the topic here.<br><\/p>\n\n\n\n<p>Suppose we want to print out every value in our <code>currencyCodes<\/code>\u201dHashMap to the console so that we can show the currency conversion business a list of the currencies they offer that are stored in the HashMap. We could use the following code to do this:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.HashMap;\nclass CurrencyExchange {\n\tpublic static void main(String[] args) {\n\t\tHashMap&lt;String, String&gt; currencyCodes = new HashMap&lt;String, String&gt;();\n\t\tcurrencyCodes.put(\"GBP\", \"Great Britain\");\n\t\tcurrencyCodes.put(\"USD\", \"United States\");\n\t\tfor(String value : currencyCodes.values()) {\n\t\t\tSystem.out.println(value);\n\t\t}\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>When we run our code, the following response is returned:<br><\/p>\n\n\n\n<p><code>Great Britain<\/code><\/p>\n\n\n\n<p><code>United States<br><\/code><\/p>\n\n\n\n<p>In our code, we use a <code>for-each<\/code> loop to iterate through every item in the list of <code>currencyCodes.values()<\/code>. Then we print out each item on a new line.<br><\/p>\n\n\n\n<p>If we wanted to iterate through every key and print out the name of each key in our HashMap, we could replace <code>values()<\/code> with <code>keySet()<\/code> in our code above. Here\u2019s what our program would return:<br><\/p>\n\n\n\n<p><code>GBP<\/code><\/p>\n\n\n\n<p><code>USD<br><\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Java HashMap class is used to store data using the key\/value collection structure. This structure is useful if you want to store two values that should be associated with each other.<br><\/p>\n\n\n\n<p>This tutorial covered the basics of HashMaps. We showed you how to create a HashMap, and explored a few examples of common HashMap methods in action. Now you\u2019re equipped with the information you need to work with Java HashMaps like an expert!<\/p>\n","protected":false},"excerpt":{"rendered":"In programming, data types are used to classify particular types of data. Each data type is stored in a different way, and the data type in which a value is stored will determine the operations which can be performed on the value. When you\u2019re working in Java, one class you may encounter is the Java&hellip;","protected":false},"author":240,"featured_media":13376,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13375","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use the Java HashMap Class | Career Karma<\/title>\n<meta name=\"description\" content=\"The Java HashMap class is used to store values in a key\/value pair using Java\u2019s Map object. Learn more in this article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-hashmap\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use the Java HashMap Class\" \/>\n<meta property=\"og:description\" content=\"The Java HashMap class is used to store values in a key\/value pair using Java\u2019s Map object. Learn more in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-hashmap\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-16T11:05:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:31:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Use the Java HashMap Class\",\"datePublished\":\"2020-03-16T11:05:33+00:00\",\"dateModified\":\"2023-12-01T10:31:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/\"},\"wordCount\":1210,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/\",\"name\":\"How to Use the Java HashMap Class | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg\",\"datePublished\":\"2020-03-16T11:05:33+00:00\",\"dateModified\":\"2023-12-01T10:31:57+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Java HashMap class is used to store values in a key\\\/value pair using Java\u2019s Map object. Learn more in this article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-hashmap\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Use the Java HashMap Class\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Use the Java HashMap Class | Career Karma","description":"The Java HashMap class is used to store values in a key\/value pair using Java\u2019s Map object. Learn more in this article.","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:\/\/careerkarma.com\/blog\/java-hashmap\/","og_locale":"en_US","og_type":"article","og_title":"How to Use the Java HashMap Class","og_description":"The Java HashMap class is used to store values in a key\/value pair using Java\u2019s Map object. Learn more in this article.","og_url":"https:\/\/careerkarma.com\/blog\/java-hashmap\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-16T11:05:33+00:00","article_modified_time":"2023-12-01T10:31:57+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Use the Java HashMap Class","datePublished":"2020-03-16T11:05:33+00:00","dateModified":"2023-12-01T10:31:57+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/"},"wordCount":1210,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-hashmap\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/","url":"https:\/\/careerkarma.com\/blog\/java-hashmap\/","name":"How to Use the Java HashMap Class | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg","datePublished":"2020-03-16T11:05:33+00:00","dateModified":"2023-12-01T10:31:57+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Java HashMap class is used to store values in a key\/value pair using Java\u2019s Map object. Learn more in this article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-hashmap\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/turned-on-silver-imac-with-might-mouse-and-keyboard-930530-1.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-hashmap\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"How to Use the Java HashMap Class"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=13375"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13375\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13376"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}