1 void Findrepeter(){
2 String s="mmababctamantlslmag";
3 int distinct = 0 ;
4
5 for (int i = 0; i < s.length(); i++) {
6
7 for (int j = 0; j < s.length(); j++) {
8
9 if(s.charAt(i)==s.charAt(j))
10 {
11 distinct++;
12
13 }
14 }
15 System.out.println(s.charAt(i)+"--"+distinct);
16 String d=String.valueOf(s.charAt(i)).trim();
17 s=s.replaceAll(d,"");
18 distinct = 0;
19
20 }
21
22}
1import java.io.*;
2public class CountChar
3{
4
5 public static void main(String[] args) throws IOException
6 {
7 String ch;
8 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
9 System.out.print("Enter the Statement:");
10 ch=br.readLine();
11 int count=0,len=0;
12 do
13 {
14 try
15 {
16 char name[]=ch.toCharArray();
17 len=name.length;
18 count=0;
19 for(int j=0;j<len;j++)
20 {
21 if((name[0]==name[j])&&((name[0]>=65&&name[0]<=91)||(name[0]>=97&&name[0]<=123)))
22 count++;
23 }
24 if(count!=0)
25 System.out.println(name[0]+" "+count+" Times");
26 ch=ch.replace(""+name[0],"");
27 }
28 catch(Exception ex){}
29 }
30 while(len!=1);
31 }
32
33}