How to Count The Number of Occurrences of a Character in a String in Java

Опубликовано: 03 Ноябрь 2024
на канале: MakeItEasy
188
17

How to Count The Number of Occurrences of a Character in a String in Java, Or Compress the given String, This program has done without using inbuilt functions, to hold the occurrences value we are using array and incrementing it by using ASCII value of character.
Example ="abc"'
ASCII value of a =97 b=98 c=99
just increase the corresponding index arr[97]++;