how to test how many of one character is in a string java

50

how to test how many of one character is in a string java -

int count = string.length() - string.replaceAll("g","").length()

Comments

Submit
0 Comments