counting repeated characters in a string in java

Solutions on MaxInterview for counting repeated characters in a string in java by the best coders in the world

showing results for - "counting repeated characters in a string in java"
Martina
16 Jan 2019
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}
Mariangel
25 Nov 2017
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}
queries leading to this page
how to find repeated characters in a string in javacheck for duplicate characters in a string javajava check for repeated characters in a stringcount number of non repeated characters in string javarepeated character in string in javahow to do get number of repeated characters in string using javajava string duplicate character countprogram to count duplicate characters in a string in javacheck the repetition of a char javahow to find the count of all repeated character in a given string in javajava program to count duplicate characters in a stringcount number of how many times characters repeated in string javahow to count duplicate characters in string javahow to take count of words which is repeated in javajava program to find duplicate characters count in a string prepbytescount the duplicate characters in a string in javaprint non repeated characters from the given string in javagetting number of duplicate characters in string javacount repeated substring in string javafind the duplicate characters in a string in javacheck for duplicated character in string javacount duplicate characters in a string javahow to find the repeated characters in a string in javajava program to find duplicate characters count in a stringremove repeated characters in a string javahow to find how much a character was repeated in a string javajava how to count repeated stringshow to get duplicate character and count from string in javaunique characters in stringcount the repeated words in javajava program to count number of repeated charastors in a string javahungrycount duplicate character in a string and print it in javacount duplicate characters in a string java 8to count number of times a letter is repeated in string in javamost repeated word in string java without sortinghow to find all non repeated characters in a string in javacount duplicate characters in a string usingjava 8count duplicate characters in a string in java 8how to count same characters in a string in javahow do i count duplicated characters in a string 3fjava program to count repeated words in a stringcount how many non repeating character in a string in javajava program to count number of repeated words in a string javahungerycount duplicate characters in a string java8java count duplicate characters in stringduplicate characters count in javahow to count repeated letters in javahow to check for repeated characters in a string in javahow to count a repeating character in string in javajava find duplicate characters in stringjava program to return the duplicate characters from given string and also maximum occurrence of that duplicate character in a string in javajava program to find the count of characters that are not repeated in the stringhow to delete repeated characters from a given two string in javawrite a program that counts the occurrences of a certain character in a given stringcount how many times char is repeated in string javacount repeated string in another string in javajava program to count number of repeated words in a stringhow to know if a character is repeated more than once in a string javacheck for repeated characters in a string javajava program to count number of repeated words in a string javahungryhow to check duplicate characters in string in javahow to count same characters in string in javafind the count of duplicate character in string in javaunique characters in string leet codejava number of repeating charactersgiven a string 2c output duplicate characters and their counts javahow to count repeated characters in a string javahow to count same characters in string javahow to check repetition of character in string in javashow duplicates of char in javano repeatation character function in javahow to check the repeated character in java stringjava program to find the repeated character in a stringcount the repeated letters in string in javacount non repeating character in a string in javahow to find how how many times a character is repeated in a string javacount duplicate letters in string java and display with that characterreturn a new string where each character is repeated the length of the the string number of times javaget repeated characters in string using javacount repeated elements in an string in javafind number of duplicate words in string javahow to count repating element in string in javacount duplicate characters in a string and return character and number javahow to find count repeated string in a sequence javafind the number of repeated characters in a stringfind duplicate characters in string javawrite a java program to count the number of times the character is repeated in the stringcount the repeated words in string in javafind the count of characters that are not repeated in the string javacount the number of duplicate characters in a string javahow to count same character in one string in javafind non repeated character in string in javacount search duplicate char in string javacount duplicate elements in string javacount number of repeated characters in string javafind duplicate characters count in a string javanumber of repeated characters in a string javarepeated characters in a string javacount all same characters in string javahow to find consecutive repeated characters in a string in javajava program to find the repeated characters in a stringhow to find duplicate characters in a string in javachecking the number of repetition of char in string javafind the repeated character in a string in javajava program to find the duplicate characters in a string and the count of repetitionletters in a string for pythonprint repeated characters of string in javahow to find repeated characters in string in javacount duplicate characters in string javahow to find count repeating string sequences in pythoncount repeated words in a string in javahow to find non repeated characters in a string in javajava program to count number of repeated letters in a string and printcount repeating characters in a string javaefficient way of finding number of repeated elements in string javahow to find all non repeated character in a string in javacount repeated characters in a string in javafinding duplicate characters in a string in javajava program to return the duplicate characters from given string and also maximum occuring of that duplicate character in a string in javahow to print count duplicate characters from string in javaprogram to count repeated characters in a string in java8count duplicates in string javajava program to count number of repeated characters in a stringhow to take count of similar string and display in javahow to know how many times is a character repeated in a string in javacount repeated elements in string in javahow to know if characters are repeated in javajava count same characters in stringhow to print all duplicate characters and their count in a string in javacount repeated characters in string using java 8counting repeated characters in a string in javacount number of duplicate characters in a string javahow to check if a string has repeated characters java in o 281 29count same characters in string javajava program to count number of repeated letters in a stringfind repeated characters in a string javafind duplicate characters in a string javahow to find how much a character is repeated in a string javacounting repeated characters in a string in java