Java find how many character repeating in a string

1 · özkan pakdil · Oct. 3, 2023, midnight
How to find how many characters are repeating in a string. @Test void anotherQ() { // Q1 -- given a String like aaabbbcccaa need to return output like a3b3c3a2. String input = "aaabbbcccazzdddxx"; char[] arr = input.toCharArray(); for (int i = 0; i < arr.length; i++) { char c = arr[i]; int charCounter = 1; System.out.print(c); while (i + 1 < arr.length && c == arr[i + 1]) { charCounter++; i++; } System.out.p...