Programming Trick's

Programming Trick's

Share

12/08/2017

Program to count the occurrence characters in the string.
void countCharOccurenceInString(String str){
char[] chars=str.toCharArray();
HashMap charCountMap= new HashMap();
for(char charStr:chars){
if(charCountMap.containsKey(charStr)){
charCountMap.put(charStr, charCountMap.get(charStr)+1);
}else{
charCountMap.put(charStr, 1);
}
}
System.out.println(charCountMap);
}

Want your business to be the top-listed Computer & Electronics Service in Pune?
Click here to claim your Sponsored Listing.

Telephone

Address


Pune
411016