Hi,

Is there any java functions are availble to find mostly repeated characters in string ?

Thanks

Recommended Answers

Not in the standard API, no.
May I guess that you have been set this as an exercise?

Jump to Post

All 2 Replies

Not in the standard API, no.
May I guess that you have been set this as an exercise?

you might try this(though no guarantees), after creating your main method:

public char getCharacterNumber(string st) {
    char[] c = st.toCharArray();
    String str = "....."(whatever you want it to be);
    int[] arrayCount = new int[equal to length of str];
    for (char a : c) {
        for (int i = 0; i < str.length()-1; i++) {
            if (str.charAt(i) == a) {
                arrayCount[i]++;
                }
            }
        }   

something along this line may help. I would also recommend getting Java Programming by Y. Daniel Lang. It's the book I used in my programming Fundamentals class, and it's extremely helpful

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.