counting the sequence of character in string java

Java
String someString = "elephant";
char someChar = 'e';
int count = 0;
  
for (int i = 0; i < someString.length(); i++) {
    if (someString.charAt(i) == someChar) {
        count++;
    }
}
Source

Also in Java: