Find duplicate charcters with occurrences in a string

 A string contain some duplicate characters.find duplicate charcter with occurrences
public class DuplicateCharsInString {
public void findDuplicateChars(String str){
Map<Character, Integer> dupMap = new HashMap<Character, Integer>();
char[] chrs = str.toCharArray();
for(Character ch:chrs){
dupMap.put(ch, dupMap.get(ch)+1);
} else {
dupMap.put(ch, 1);
Set<Character> keys = dupMap.keySet();
for(Character ch:keys){
if(dupMap.get(ch) > 1){

public static void main(String a[]){
DuplicateCharsInString dcs = new DuplicateCharsInString();


 Related Posts:


Check a string value is Integer or not in java. (Solution).

Check  string is hexadecimal number or not (Solution).

Generate Combination in java (Solution).

Generate permutation of string(Solution).

Reverse string in java (Solution).

Find duplicate characters with occurrences in a string(Solution).

Permutation of a number(Soluion).

Split the String in java(Solution).

Convert string into number in java(Solution).

Swap two strings without using any variable(Solution).

Get a number from a string in java(Solution).

Add Two Big Number In Java(Solution).

Expand String(Solution).

Reverse String (Solution).

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 75 = 81