tag:blogger.com,1999:blog-5327046495053561503.post4751408219549149478..comments2023-07-25T13:09:12.340+05:30Comments on Tech Tutorials: Find Duplicate Characters in a String With Repetition Count Java ProgramAnshudeephttp://www.blogger.com/profile/05912349277663872766noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-5327046495053561503.post-65285033081880382422022-05-17T18:24:49.650+05:302022-05-17T18:24:49.650+05:30public static void main(String[] args) {
// TODO...public static void main(String[] args) {<br /> // TODO Auto-generated method stub<br /><br /> String s="aaabbbccc";<br /> s=s.replace(" ", "");<br /> char[] ch=s.toCharArray();<br /> int count=1;<br /> int match_count=1;<br /> for(int i=0;i<=s.length()-1;i++){<br /> <br /> if(ch[i]!='0'){<br /> <br /> for(int j=i+1;j<=s.length()-1;j++){<br /> <br /> if(ch[i]==ch[j])<br /> {<br /> match_count++;<br /> ch[j]='0';<br /> }<br /> else{<br /> count=1;<br /> }<br /> }<br /> if(match_count>1&& ch[i]!='0'){<br /> System.out.println("Duplicate Character is "+ch[i]+" appeared "+match_count +" times");<br /> match_count=1;<br /> }<br /> }<br /> }<br /> }<br /> Anonymousnoreply@blogger.com