duplicate characters in a string java using hashmap
Connect and share knowledge within a single location that is structured and easy to search. Then this map is iterated by getting the EntrySet from the Map and filter() method of Java Stream is used to filter out space and characters having frequency as 1. If you are not using HashMap then you can iterate the passed String in an outer and inner loop and check if the characters are equal or not. These three characters (m, g, r) appears more than once in a string. The set data structure doesn't allow duplicates and lookup time is O (1) . PTIJ Should we be afraid of Artificial Intelligence? Please mail your requirement at [emailprotected] Duration: 1 week to 2 week. Technology Blog Where You Find Programming Tips and Tricks, //Find duplicate characters in a string using HashMap, //Using set find duplicate letters in a string, //If character is already present in a set, Find Maximum Difference between Two Elements of an Array, Find First Non-repeating Character in a String Java Code, Check whether Two Strings are Anagram of each other, Java Program to Find Missing Number in Array, How to Access Localhost from Anywhere using Any Device, How To Install PHP, MySql, Apache (LAMP) in Ubuntu, How to Copy File in Linux using CP Command, PHP Composer : Manage Package Dependency in PHP. This java program can be done using many ways. Splitting word using regex '\\W'. In this short article, we will write a Java program to count duplicate characters in a given String. We use a HashMap and Set to find out which characters are duplicated in a given string. Connect and share knowledge within a single location that is structured and easy to search. I am trying to implement a way to search for a value in a dictionary using its corresponding key. Was Galileo expecting to see so many stars? If equal, then increment the count. If the character is not already in the Map then add it with a count of 1. You are iterating by using the hashmapsize and indexing into the array using the count which is wrong. In this video tutorial, I have explained multiple approaches to solve this problem. Also note that chars() method of String class is used in the program which is available Java 9 onward. Complete Data Science Program(Live) Below is the implementation of the above approach: Remove all duplicate adjacent characters from a string using Stack, Count the nodes of a tree whose weighted string does not contain any duplicate characters, Find the duplicate characters in a string in O(1) space, Lexicographic rank of a string with duplicate characters, Java Program To Remove All The Duplicate Entries From The Collection, Minimum number of operations to move all uppercase characters before all lower case characters, Min flips of continuous characters to make all characters same in a string, Make all characters of a string same by minimum number of increments or decrements of ASCII values of characters, Modify string by replacing all occurrences of given characters by specified replacing characters, Minimize cost to make all characters of a Binary String equal to '1' by reversing or flipping characters of substrings. This is the implementation without using any Collection and with complexity order of n. Although the accepted solution is good enough and does not use Collection as well but it seems, it is not taking care of special characters. Program for array left rotation by d positions. If the character is already present in a set, it means its a duplicate character. Java Program to Count Duplicate Characters in a String Author: Ramesh Fadatare Java Programs String Programs In this quick post, we will write a Java Program to Count Duplicate Characters in a String. Fastest way to determine if an integer's square root is an integer. Inside this two nested structure for loops, you have to use an if condition which will check whether inp[i] is equal to inp[j] or not. you can also use methods of Java Stream API to get duplicate characters in a String. A note on why it's inefficient: The time complexity of this program is O(n^2) which is unacceptable for n(length of the string) too large. The solution to counting the characters in a string (including. If the character is not already in the Map then add it with a count of 1. Copyright 2020 2021 webrewrite.com All Rights Reserved. If youre looking to remove duplicate or repeated characters from a String in Java, this is the page for you! Then create a hashmap to store the Characters and their occurrences. What does meta-philosophy have to say about the (presumably) philosophical work of non professional philosophers? Iterate over List using Stream and find duplicate words. You need iterate over each character of your string, and check whether its an alphabet. acknowledge that you have read and understood our, Data Structure & Algorithm Classes (Live), Data Structure & Algorithm-Self Paced(C++/JAVA), Android App Development with Kotlin(Live), Full Stack Development with React & Node JS(Live), GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Tree Traversals (Inorder, Preorder and Postorder), Dijkstra's Shortest Path Algorithm | Greedy Algo-7, Binary Search Tree | Set 1 (Search and Insertion), Write a program to reverse an array or string, Largest Sum Contiguous Subarray (Kadane's Algorithm). For each character check in HashMap if char already exists; if yes then increment count for the existing char, if no then add the char to the HashMap with the initial . Truce of the burning tree -- how realistic? I tried to use this solution but I am getting: an item with the same key has already been already. Find centralized, trusted content and collaborate around the technologies you use most. Hello, In this post we will see Program to find duplicate characters in a string in Java, find duplicate characters in a string java without using hashmap, program to remove duplicate characters in a string in java etc. We use a HashMap and Set to find out which characters are duplicated in a given string. Coding-Ninja-Java_Fundamentals / Strings / Remove_Consecutive_Duplicates.java Go to file Go to file T; Go to line L; Copy path . If count is greater than 1, it implies that a character has a duplicate entry in the string. How to directly initialize a HashMap (in a literal way)? BrowserStack Interview Experience | Set 2 (Coding Questions), BrowserStack Interview Experience | Set 3 (Coding Questions), BrowserStack Interview Experience | Set 4 (On-Campus), BrowserStack Interview Experience | Set 5 (Fresher), BrowserStack Interview Experience | Set 6 (On-Campus), BrowserStack Interview Experience | Set 7 (Online Coding Questions), BrowserStack Interview Experience | Set 1 (On-Campus), Remove comments from a given C/C++ program, C++ Program to remove spaces from a string, URLify a given string (Replace spaces with %20), Program to print all palindromes in a given range, Check if characters of a given string can be rearranged to form a palindrome, Rearrange characters to form palindrome if possible, Check if a string can be rearranged to form special palindrome, Check if the characters in a string form a Palindrome in O(1) extra space, Sentence Palindrome (Palindrome after removing spaces, dots, .. etc), Python program to check if a string is palindrome or not, Reverse words in a given String in Python, Convert a String to Character Array in Java, Implementing a Linked List in Java using Class, Java Program to find largest element in an array. You could use the following, provided String s is the string you want to process. Java code examples and interview questions. Ah, maybe some code will make it clearer: Using Eclipse Collections CharAdapter and CharBag: Note: I am a committer for Eclipse Collections, Simple and Easy way to find char occurrences >, {T=1, h=2, e=4, =8, q=1, u=2, i=1, c=1, k=1, b=1, r=2, o=4, w=1, n=1, f=1, x=1, j=1, m=1, p=1, d=2, v=1, t=1, l=1, a=1, z=1, y=1, g=1, .=1}. In each iteration check if key Why doesn't the federal government manage Sandia National Laboratories? Then, when adding the next character use indexOf() method on the string builder to check if that char is already present in the string builder. In case characters are equal you also need to remove that character Another nested for loop has to be implemented which will count from i+1 till length of string. find duplicates using HashMap [duplicate]. What capacitance values do you recommend for decoupling capacitors in battery-powered circuits? The open-source game engine youve been waiting for: Godot (Ep. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. This cnt will count the number of character-duplication found in the given string. We will try to Find Duplicate Characters In a String Java in two ways: I find this exercise beneficial for beginners as it allows them to get comfortable with the Map data structure. */ for(Character ch:keys) { if(map.get(ch) > 1) { System.out.println("Char "+ch+" "+map.get(ch)); } } } public static void main(String a[]) { Details obj = new Details(); System.out.println("String: BeginnersBook.com"); System.out.println("-------------------------"); At what point of what we watch as the MCU movies the branching started? We can remove the duplicate character in the following ways: This problem can be solved by using the StringBuilder. open the file in an editor that reveals hidden Unicode characters. First we have converted the string into array of character. METHOD 1 (Simple) Java import java.util. Try this for (Map.Entry<String, Integer> entry: hashmap.entrySet ()) { int target = entry.getValue (); if (target > 1) { System.out.print (entry.getKey ()); } } How do you find duplicate characters in a string? Here To find out the duplicate character, we have used the java collection concept. In this program, we need to find the duplicate characters in the string. All rights reserved. Learn Java programming at https://www.javaguides.net/p/java-tutorial-learn-java-programming.html. are equal or not. A-143, 9th Floor, Sovereign Corporate Tower, We use cookies to ensure you have the best browsing experience on our website. What is the difference between public, protected, package-private and private in Java? A Computer Science portal for geeks. Inside the main(), the String type variable name stris declared and initialized with string w3schools. If it is present, then increase its count using get () and put () function in Hashmap. Why String is popular HashMap key in Java? If it is present, then increment the count or else insert the character in the hashmap with frequency = 1. How to derive the state of a qubit after a partial measurement? Once we know how many times each character occurred in a string, we can easily print the duplicate. Then we extract all the keys from this HashMap using the keySet() method, giving us all the duplicate characters. By using our site, you All duplicate chars would be * having value greater than 1. here is my solution.!! Given a string S, you need to remove all the duplicates. Spring code examples. 1 Answer Sorted by: 0 You are iterating by using the hashmap size and indexing into the array using the count which is wrong. So, in our case key is the character and value is its count. Explanation: There are no duplicate words present in the given Expression. Traverse in the string, check if the Hashmap already contains the traversed character or not. How do I count the number of occurrences of a char in a String? 542), How Intuit democratizes AI development across teams through reusability, We've added a "Necessary cookies only" option to the cookie consent popup. Input format: The first and only line of input contains a string, that denotes the value of S. Output format : example: Scanner scan = new Scanner(System.in); Map<String, String> newdict = new HashMap<. from the String so that it is not counted again in further iterations. A HashMap is a collection that stores items in a key-value pair. Help me understand the context behind the "It's okay to be white" question in a recent Rasmussen Poll, and what if anything might these results show. Is a hot staple gun good enough for interior switch repair? Please do not add any spam links in the comments section. Complete Data Science Program(Live . Java program to reverse each words of a string. We will discuss two solutions to count duplicate characters in a String: HashMap based solution Java 8, functional-style solution JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. STEP 1: START STEP 2: DEFINE String string1 = "Great responsibility" STEP 3: DEFINE count STEP 4: CONVERT string1 into char string []. In this tutorial, I am going to explain multiple approaches to solve this problem.. Example programs are shown in various java versions such as java 8, 11, 12 and Surrogate Pairs. The second value should just replace the previous value. Map<Character, Integer> baseMap = new HashMap<Character, Integer> (); public void findIt (String str) {. To find the frequency of each character in a string, we can use a HashMap in Java. can store each char of the String as a key and starting count as 1 which becomes the value. Please use formatting tools to properly edit and format your question/answer. Approach: The idea is to do hashing using HashMap. You can use the hashmap in Java to find out the duplicate characters in a string -. Then we have used Set and keySet() method to extract the set of key and store into Set collection. Codes within sentences are to be formatted as, Find duplicate characters in a String and count the number of occurrences using Java, The open-source game engine youve been waiting for: Godot (Ep. Not the answer you're looking for? Thanks! HashMap<Integer, String> hm = new HashMap<Integer, String> (); With the above statement the system can understands that we are going to store a set of String objects (Values) and each such object is identified by an Integer object (Key). For example, the frequency of the character 'a' in the string "banana" is 3. Create a hashMap of type {char, int}. Gratis mendaftar dan menawar pekerjaan. File: DuplicateCharFinder .java. Why are non-Western countries siding with China in the UN? i) Declare a set which holds the value of character type. Integral with cosine in the denominator and undefined boundaries. This Java program is used to find duplicate characters in string. If it is present, then increment the count or else insert the character in the hashmap with frequency = 1. Copyright 2011-2021 www.javatpoint.com. Tricky Java coding interview questions part 2. Mail us on [emailprotected], to get more information about given services. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. Finding duplicates characters in a String and the repetition count program is easy to write using a Find centralized, trusted content and collaborate around the technologies you use most. This cnt will count the number of character-duplication found in the given string. How do I create a Java string from the contents of a file? If you are using an older version, you should use Character#isLetter. In this example, we are going to use another data structure know as set to solve this problem. It first creates an array from given string using split method and then after considers as any word duplicate if a word come atleast two times. Dealing with hard questions during a software developer interview. Reference - What does this error mean in PHP? Check whether two Strings are Anagram of each other using HashMap in Java, Convert String or String Array to HashMap In Java, Java program to count the occurrences of each character. In this blog post, we will learn a java program tofind the duplicate characters in astring. Traverse the string, check if the hashMap already contains the traversed character or not. You can also achieve it by iterating over your String and using a switch to check each individual character, adding a counter whenever it finds a match. Full Stack Development with React & Node JS(Live) Java Backend Development(Live) React JS (Basic to Advanced) JavaScript Foundation; Machine Learning and Data Science. REPEAT STEP 8 to STEP 10 UNTIL j In this program an approach using Hashmap in Java has been discussed. Why does the impeller of torque converter sit behind the turbine? Store all Words in an Array. A-143, 9th Floor, Sovereign Corporate Tower, We use cookies to ensure you have the best browsing experience on our website. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Approach 1: Get the Expression. Now we can use the above Map to know the occurrences of each char and decide which chars are duplicates or unique. Find duplicate characters in a String Java program using HashMap. But, we will focus on using the Brute-force search approach, HashMap or LinkedHashMap, Java 8 compute () and Java 8 functional style. public static void main(String[] args) {// TODO Auto-generated method stubString s="aaabbbccc";s=s.replace(" ", "");char[] ch=s.toCharArray();int count=1;int match_count=1;for(int i=0;i<=s.length()-1;i++){if(ch[i]!='0'){for(int j=i+1;j<=s.length()-1;j++){if(ch[i]==ch[j]){match_count++;ch[j]='0';}else{count=1;}}if(match_count>1&& ch[i]!='0'){System.out.println("Duplicate Character is "+ch[i]+" appeared "+match_count +" times");match_count=1;}}}}, Java program to find duplicate characters in a String without using any library, Java program to find duplicate characters in a String using HashMap, Java program to find duplicate characters in a String using Java Stream, Find duplicate characters in a String wihout using any library, Find duplicate characters in a String using HashMap, Find duplicate characters in a String using Java Stream, Convert String to Byte Array Java Program, Add Double Quotes to a String Java Program, Java Program to Find First Non-Repeated Character in a Given String, Compress And Decompress File Using GZIP Format in Java, Producer-Consumer Java Program Using ArrayBlockingQueue, New Date And Time API in Java With Examples, Exception Handling in Java Lambda Expressions, Java String Search Using indexOf(), lastIndexOf() And contains() Methods. How do I efficiently iterate over each entry in a Java Map? All Java program needs one main() function from where it starts executing program. A quick practical and best way to find or count the duplicate characters in a string including special characters. Is there a more recent similar source? REPEAT STEP 7 to STEP 11 UNTIL i STEP 7: SET count =1 STEP 8: SET j = i+1. Yes, indeed, till Java folks have not stopped working :), Add some explanation with answer for how this answer help OP in fixing current issue. Learn more about bidirectional Unicode characters. already exists, if yes then increment the count (by accessing the value for that key). Is a hot staple gun good enough for interior switch repair? In this video, we will write a Java Program to Count Duplicate Characters in a String.We will discuss two solutions to count duplicate characters in a String. Could you provide an explanation of your code and how it is different or better than other answers which have already been provided? If it is an alphabet, increase its count in the Map. The number of distinct words in a sentence, Duress at instant speed in response to Counterspell. In this post well see a Java program to find duplicate characters in a String along with repetition count of the duplicates. Program to Convert HashMap to TreeMap in Java, Java Program to Sort a HashMap by Keys and Values, Converting ArrayList to HashMap in Java 8 using a Lambda Expression. Traverse in the string, check if the Hashmap already contains the traversed character or not. If the condition becomes true prints inp[j] using System.out.println() with s single incrementation of variable cntand then break statement will be encountered which will move the execution out of the loop. Below are the different methods to remove duplicates in a string. Is something's right to be free more important than the best interest for its own species according to deontology? Applications of super-mathematics to non-super mathematics. accumulo,1,ActiveMQ,2,Adsense,1,API,37,ArrayList,18,Arrays,24,Bean Creation,3,Bean Scopes,1,BiConsumer,1,Blogger Tips,1,Books,1,C Programming,1,Collection,8,Collections,37,Collector,1,Command Line,1,Comparator,1,Compile Errors,1,Configurations,7,Constants,1,Control Statements,8,Conversions,6,Core Java,149,Corona India,1,Create,2,CSS,1,Date,3,Date Time API,38,Dictionary,1,Difference,2,Download,1,Eclipse,3,Efficiently,1,Error,1,Errors,1,Exceptions,8,Fast,1,Files,17,Float,1,Font,1,Form,1,Freshers,1,Function,3,Functional Interface,2,Garbage Collector,1,Generics,4,Git,9,Grant,1,Grep,1,HashMap,2,HomeBrew,2,HTML,2,HttpClient,2,Immutable,1,Installation,1,Interview Questions,6,Iterate,2,Jackson API,3,Java,32,Java 10,1,Java 11,6,Java 12,5,Java 13,2,Java 14,2,Java 8,128,Java 8 Difference,2,Java 8 Stream Conversions,4,java 8 Stream Examples,12,Java 9,1,Java Conversions,14,Java Design Patterns,1,Java Files,1,Java Program,3,Java Programs,114,Java Spark,1,java.lang,4,java.util. Set to find out the duplicate character, we use cookies to ensure you have the best browsing on! Explanation of your code and how it is present, then increment the count ( by accessing the of! Information about given services string you want to process approach using HashMap in Java has been.. You should use character # isLetter items in a sentence, Duress at instant in! In astring Strings / Remove_Consecutive_Duplicates.java Go to line L ; Copy path tofind the duplicate characters in string an. Can remove the duplicate use formatting tools to properly edit and format your question/answer see a Java to. An older version, you all duplicate chars would be * having greater! Is available Java 9 onward set collection Java to find out the character! Time is O ( 1 ) the page for you line duplicate characters in a string java using hashmap ; Copy path to be more. Extract all the duplicates use the following ways: this problem other tagged... 2 week Duress at instant speed in response to Counterspell speed in response to.... We will write a Java Map such as Java 8, 11, and! Copy path use methods of Java Stream API to get more information about given services character-duplication... These three characters ( m, g, r ) appears more than once in duplicate characters in a string java using hashmap string including characters... Siding with China in the string type variable name stris declared and with... In string coworkers, Reach developers & technologists worldwide I count the duplicate characters in a Java program is to... Have already been already ensure you have the best interest for its own species according to deontology this error in. Multiple approaches to solve this problem can be solved by using the hashmapsize and indexing into the array using count... File in an editor that reveals hidden Unicode characters to determine if an integer item with the same key already... Need to find out which characters are duplicated in a literal way ) this error mean in PHP developer.. Use another data structure doesn & # x27 ; t allow duplicates and time... Is its count using get ( ) method of string class is used to find out the duplicate in! We need to find duplicate characters in a set, it implies that character... Its a duplicate entry in a sentence, Duress at instant speed in response to Counterspell store the in! Interview questions ; Copy path =1 STEP 8 to STEP 11 UNTIL I 7... Impeller of torque converter sit behind the turbine HashMap already contains the traversed character or not package-private and in..., I have explained multiple approaches to solve this problem with hard questions a! The following, provided string s is the string into array of character type and best to. This solution but I am trying to implement a way to determine if an integer 's square is! Are iterating by using the StringBuilder using regex & # 92 ; W & # ;! Species according to deontology content and collaborate around the technologies you use most for its own species according to?. Character occurred in a string Java program using HashMap in Java is something 's right be. String type variable name stris declared and initialized with string w3schools Strings Remove_Consecutive_Duplicates.java... Once duplicate characters in a string java using hashmap a string and undefined boundaries 7 to STEP 10 UNTIL j this. Present, then increase its count in the comments section splitting word using &! Sovereign Corporate Tower, we use cookies to ensure you have the best browsing experience on our.. This Java program using HashMap implies that a character has a duplicate character in the given Expression string. I tried to use this solution but I am trying to implement a way find. These three characters ( m, g, r ) appears more than once in a,! Instant speed in response to Counterspell: 1 week to 2 week char and decide chars. Char in a string ( including if key why does n't the federal manage! Been discussed Java 8, 11, 12 and Surrogate Pairs a character has a duplicate entry in given!, protected, package-private and private in Java to find out the duplicate characters, r ) appears than... Each entry in the string versions such as Java 8, 11, 12 and Surrogate Pairs HashMap duplicate characters in a string java using hashmap! Program tofind the duplicate character in the string, we can remove the.! ), the string as a key and store into set collection out which characters are duplicated in string... Count which is wrong by accessing the value a software developer interview each iteration check if character... Each entry in a string including special characters count using get ( method! Version, you should use character # isLetter, to get more information about given services ways: this..! It starts executing program going to use another data structure know as set to find out which characters are in. Chars would be * having value greater than 1, it implies that a character has a duplicate character is! S is the difference between public, protected, package-private and private in Java has duplicate characters in a string java using hashmap discussed non-Western countries with... Cookies to ensure you have the best interest for its own species according to deontology solution.! a key-value.. For interior switch repair cookies to ensure you have the best browsing experience on website... Public, protected, package-private and private in Java, this is the string type variable name stris and. ( ) and put ( ) method of string class is used to find the frequency of each character the! No duplicate words solve this problem a key-value pair it with a count of 1 used in the program is... Number of distinct words in a set which holds the value tools to properly edit format... Solution to counting the characters and their occurrences this HashMap using the StringBuilder it implies that character! Be * having value greater than 1, it implies that a has. If an integer 's square root is an integer duplicate characters in a string java using hashmap 7 to STEP UNTIL! As Java 8, 11, 12 and Surrogate Pairs hidden Unicode characters and. Into the array using the count which is wrong browsing experience on our website a HashMap ( in string... Then increase its count using get ( ) method of string class is used to out... We are going to explain multiple approaches to solve this problem can be done using many ways a?! Hashmapsize and indexing into the array using the hashmapsize and indexing into the array using the.... Can remove the duplicate characters in a key-value pair, to get duplicate characters string. Connect and share knowledge within a single location that is structured and easy to search sentence Duress... Remove_Consecutive_Duplicates.Java Go to line L ; Copy path quizzes and practice/competitive programming/company interview questions video,! Do I count the number of occurrences of each character of your code and how duplicate characters in a string java using hashmap present! Tutorial, I am getting: an item with the same key has already been already a. And keySet ( ) method, giving us all the duplicates the following ways: this problem of! If youre looking to remove duplicate or repeated characters from a string, if... The different methods to remove duplicates in a given string method to extract the set data structure doesn & x27... And well explained computer science and programming articles, quizzes and practice/competitive programming/company interview questions having value greater than,. A literal way ) well explained computer science and programming articles, quizzes practice/competitive! Count =1 STEP 8 to STEP 10 UNTIL j in this example, we use a HashMap and set find! Please mail your requirement at [ emailprotected ], to get more information about given services STEP UNTIL. Of type { char, int } declared and initialized with string w3schools in an editor that reveals hidden characters... Time is O ( 1 ) List using Stream and find duplicate words present in comments! Response to Counterspell do hashing using HashMap in Java, this is the difference between public, protected package-private! Which have already been already to properly edit and format your question/answer an item the. A partial measurement coding-ninja-java_fundamentals / Strings / Remove_Consecutive_Duplicates.java Go to file Go to line L ; Copy.. Duplicated in a string along with repetition count of 1 given services post well see a Java program tofind duplicate! Are shown in various Java versions such as Java 8, 11 12! If count is greater than 1. here is my solution.! this example, we use cookies to you! Presumably ) philosophical work of non professional philosophers that key ) sit behind the turbine these three characters (,... Is O ( 1 ) in Java staple gun good enough for interior switch repair method, giving us the... Copy path: There are no duplicate words Java has been discussed the keySet ( ) method, giving all. Set to find duplicate characters in a Java program to reverse each of! Program an approach using HashMap would be * having value greater than 1. here my. Use most line L ; Copy path does the impeller of torque converter behind! Week to 2 week to line L ; Copy path name stris declared and initialized with w3schools! Engine youve been waiting for: Godot ( Ep: the idea is to do hashing using HashMap from... This cnt will count the number of distinct words in a string string Java program the... Explained multiple approaches to solve this problem not counted again in further iterations browse other tagged... Program, we will learn a Java program is used in the Map than 1. here my... 1 which becomes the value and Surrogate Pairs editor that reveals hidden Unicode characters count =1 STEP:... Corresponding key each iteration check if the HashMap with frequency = 1 7: set count =1 STEP 8 set. Switch repair main ( ) method, giving us all the keys from this HashMap using the or!
duplicate characters in a string java using hashmap